<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width, initial-scale=1.0"><title>await/async案例笔记</title></head><body><scripttype="text/javascript">functiondelayGetTime(){returnnewPromise((resolve, reject)=>{setTimeout(()=>{resolve(Date.now())},2000)})}asyncfunctionsyncTest(){let result =[];result.push(awaitdelayGetTime())result.push(awaitdelayGetTime())return result
}(async()=>{console.log(1)console.log(awaitsyncTest());console.log(2)// 没有await堵塞又按主线程控制先同步后异步,先宏任务后微任务delayGetTime().then(t=> console.log(t));console.log(3)})();</script></body></html>
有一个水壶容量或者两个水壶加起来总容量为目标容量
总共有八种选择:第一种倒满x,第二种倒满y,第三种清空x,第四种清空y,第五种x 倒给 y y能装满 ,第六种 x 倒给 y x倒完, 。。。。
这里用深度遍历,时间超时
class Solution {public boole…