上一页 1 2 3 4 5 6 ··· 28 下一页
摘要: 小心这里是index triplets, 不是nums[i]数组元素的triplets, 所以3Sum那道题里面的跳过条件不用了 因为不关心每个index具体是什么,只关心个数,所以可以排序 阅读全文
posted @ 2017-12-20 10:36 apanda009 阅读(141) 评论(0) 推荐(0) 编辑
摘要: Time Complexity will be O(n) because the "start" and "end" points will only move from left to right once. 阅读全文
posted @ 2017-12-20 06:24 apanda009 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 我又想到了另一个idea,使用那个assumption可以达到O(1) 复杂度:首先判断isUp or not,仅以isUp为例, 假设A[x] 是最高点,则有:A[x] - A[i] = x - i. A[x] - A[j] = j - x由此可以解出 x = 1/ 2 * (A[j] - A[i 阅读全文
posted @ 2017-12-20 02:49 apanda009 阅读(155) 评论(0) 推荐(0) 编辑
摘要: A->B->C->D->E | V M | V N 有right和down的linkedlist,要求更新linkedlist变成A->M->N->B->C->D->E,注意M可以还有right,B也可以有down,其实就是递归输出。然后我做了一会才做出,之前有个大神的面经里发过,但我没仔细看很后悔。我昨晚发现这tmd不是inorder traversal么 // Class to ... 阅读全文
posted @ 2017-12-13 01:05 apanda009 阅读(255) 评论(0) 推荐(0) 编辑
摘要: 写了一行,面试官打断我,让我再说一下思路,我又说了一下准备定义一个array,n+1的size,第一个存0,保存到当前值的所有之前numbers的和,然后比如query(0,3),就能用preSum[4]-preSum[0];他表示不懂...我又举了3个例子...面试官表示ok,但你不要写代码,先写 阅读全文
posted @ 2017-12-13 00:12 apanda009 阅读(163) 评论(0) 推荐(0) 编辑
摘要: The idea is to use two arrays len[n] and cnt[n] to record the maximum length of Increasing Subsequence and the coresponding number of these sequence w 阅读全文
posted @ 2017-12-13 00:00 apanda009 阅读(169) 评论(0) 推荐(0) 编辑
摘要: what if the list doesn't contains the result? 阅读全文
posted @ 2017-12-08 06:58 apanda009 阅读(186) 评论(0) 推荐(0) 编辑
摘要: Write a program that takes an integer and prints out all ways to multiply smaller integers that equal the original number, without repeating sets of factors. In other words, if your output contains 4... 阅读全文
posted @ 2017-12-07 23:19 apanda009 阅读(158) 评论(0) 推荐(0) 编辑
摘要: Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: "Let's take LeetCode contest" O... 阅读全文
posted @ 2017-12-06 12:21 apanda009 阅读(162) 评论(0) 推荐(0) 编辑
摘要: Approach #2: Double Linked List + TreeMap [Accepted] Intuition Using structures like Array or Stack will never let us popMax quickly. We turn our atte 阅读全文
posted @ 2017-12-03 11:33 apanda009 阅读(338) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 28 下一页