分类: LeetCode OJ

评分 0, 满分 5 星
0 票

设计了一个状态,即搜索到pos位置时结果是str并且左右括号个数分别是nl和nr,这个状态在搜索的时候很方便转移并且能即时判断结果的合理性,但是有一个缺点就是状态数目太多了,搜索的时候去重比较麻烦,并且不剪枝也会T。// 我不知道怎么会写出这么恶心的程序。

#
Comments Off on [LeetCode]Remove Invalid Parentheses

评分 0, 满分 5 星
0 票

4个石子,后手总会赢。如果石子个数不是4的整数倍,那么先手可以取走一部分石子(1, 2, 3)使得剩下的石子数目是4的整数倍,接下来的博弈中先手变后手,总会赢。

#
Comments Off on [LeetCode]Nim Game

评分 0, 满分 5 星
0 票

Classical problem, try to finish it within 10 mins... // Coding 10 mins, debugging 5mins!!! It took me nearly 15 mins to solve it, time is so cruel...

Comments Off on [LeetCode]Multiply Strings

评分 0, 满分 5 星
0 票

For a random index m, compare nums[m] with its neighbor, one of the answer belongs to the interval that the bigger element belongs to too, and we can optimize our program based on this.

评分 0, 满分 5 星
0 票

Notice the result(one-digit number) of the numbers is a periodic sequence...

Comments Off on [LeetCode]Add Digits

评分 0, 满分 5 星
0 票

Here is a direct solution: keep narrowing the scope of matrix, and at the end, either the target doesn't belong to the matrix or the target appears in the scope's right-up corner as well as left-down corner.

Comments Off on [LeetCode]Search a 2D Matrix II

评分 5.00, 满分 5 星
1 票

The data structure we selected in this problem should satisfy at least two conditions: 1) monotonicity, which guarantees in every sliding window we could always get the max element; 2) FIFO, which ensures the problem could be solved in linear time.