上一页 1 2 3 4 5 6 7 8 9 10 ··· 13 下一页
摘要: https://leetcode.com/problems/find-peak-element/description/A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return... 阅读全文
posted @ 2018-03-20 00:15 davidnyc 阅读(114) 评论(0) 推荐(0)
摘要: 如果有特别多重复的数进来的情况,并且是一整块一样的数进来,那是可以被优化的。 1111111 222222 -1-1-1-1 111111 -2-2-2-2-2 33333 如果 进来的数字是交叉的,则优化空间有限: 1212121212 阅读全文
posted @ 2018-03-19 09:31 davidnyc 阅读(202) 评论(0) 推荐(0)
摘要: 这种写法 stack 1 stack 2 同步操作,stack 1 进来一个 stack2 也要进来一个。如果有特别多重复的数进来的情况,并且是一整块一样的数进来,那是可以被优化的。 1111111 222222 -1-1-1-1 111111 -2-2-2-2-2 33333 如果 进来的数字是交 阅读全文
posted @ 2018-03-19 08:53 davidnyc 阅读(252) 评论(0) 推荐(0)
摘要: 重要假设,必须要时刻知道queue 的 size 如果不知道,则做不了。 阅读全文
posted @ 2018-03-19 08:16 davidnyc 阅读(135) 评论(0) 推荐(0)
摘要: https://leetcode.com/problems/implement-stack-using-queues/description/Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on t... 阅读全文
posted @ 2018-03-19 05:31 davidnyc 阅读(144) 评论(0) 推荐(0)
摘要: worse case出现在 所有元素都在stack1 中,第一次 从 stack2 中 pop 阅读全文
posted @ 2018-03-19 03:55 davidnyc 阅读(237) 评论(0) 推荐(0)
摘要: TEST: 阅读全文
posted @ 2018-03-19 02:24 davidnyc 阅读(300) 评论(0) 推荐(0)
摘要: 注意针对 rotated sorted array 去重复的固定套路 参考 33,81,153, 154 阅读全文
posted @ 2018-03-17 09:31 davidnyc 阅读(118) 评论(0) 推荐(0)
摘要: https://leetcode.com/problems/search-in-rotated-sorted-array-ii/description/Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How... 阅读全文
posted @ 2018-03-17 04:52 davidnyc 阅读(135) 评论(0) 推荐(0)
摘要: https://leetcode.com/problems/search-insert-position/description/Given a sorted array and a target value, return the index if the target is found.If not, return the index where it would be if it were ... 阅读全文
posted @ 2018-03-17 02:50 davidnyc 阅读(129) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 10 ··· 13 下一页