摘要:
Solution: Use Stack, O(N) space my another solution: don't create new node, modify the existed node Solution 3: reverse the inputs, add one, then reve 阅读全文
摘要:
参考:https://discuss.leetcode.com/topic/48424/java-o-n-incredibly-short-yet-easy-to-understand-ac-solution the problem seems to have many cases a>0, a=0 阅读全文
摘要:
Analysis: Solution 1: The greedy algorithm is that in each step, select the char with highest remaining count if possible (if it is not in the waiting 阅读全文
摘要:
本题精妙之处在于:1. 如何最快找到possible的line的x axis(我最开始想到要用quickselect find median的方法,结果别人有min max方法) 2. 如何最方便确定一个点关于该line的reflection是否存在,由于既有x又有y,不太好处理,别人有个聪明的办法 阅读全文
摘要:
HashMap 阅读全文
摘要:
HashSet + Queue: 吃东西的时候保留尾巴,不吃的时候删去尾巴 one case to notice蛇转弯的时候,要先删去尾巴,再把新的点加进去。如果这个顺序不对的话,本来不会撞上尾巴的结果会判断会撞上 如果没有39行,程序会说dir没有initialize, 其实更好的写法应该是 阅读全文
摘要:
我自己的backtracking做法 最开始把cur设置为一个dummy value 0 最好的DFS with Optimization beat 97%: https://discuss.leetcode.com/topic/46260/java-dfs-solution-with-clear- 阅读全文