随笔分类 -  BB

摘要:private static void remove(String s) { if (s == null || s.length() == 0) { return; } StringBuilder sb = new StringBuilder(); Stack st1 = new Stack(); ... 阅读全文
posted @ 2018-10-02 02:23 apanda009 阅读(98) 评论(0) 推荐(0)
摘要:Design and implement a data structure for Least Frequently Used (LFU) cache. It should support the following operations: get and put. get(key) - Get t 阅读全文
posted @ 2018-07-05 03:10 apanda009 阅读(221) 评论(0) 推荐(0)
摘要:We can also do it without modifying the input by using a variable prev to hold the a[i-1]; if we have to lower a[i] to match a[i-1] instead of raising 阅读全文
posted @ 2017-10-13 08:37 apanda009 阅读(162) 评论(0) 推荐(0)
摘要:You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note:You have to rotate the image in-place, which 阅读全文
posted @ 2017-09-24 22:45 apanda009 阅读(113) 评论(0) 推荐(0)
摘要:第一想法是用HashSet<ListNode>, A list先遍历,存HashSet,然后B list遍历,发现ListNode存在就返回。但是这个方法不满足O(1)memory的要求。 再想了一会儿,略微受了点提醒,发现可以利用这个O(n) time做文章。这个条件方便我们scan list几次 阅读全文
posted @ 2017-08-19 18:20 apanda009 阅读(166) 评论(0) 推荐(0)
摘要:The key of this problem is to think of using Stack, 阅读全文
posted @ 2017-08-16 22:10 apanda009 阅读(152) 评论(0) 推荐(0)
摘要:这道题还是对于Integer的处理,在Reverse Integer这道题中我有提到,这种题的考察重点并不在于问题本身,而是要注意corner case的处理,整数一般有两点,一个是正负符号问题,另一个是整数越界问题。思路比较简单,就是先去掉多余的空格字符,然后读符号(注意正负号都有可能,也有可能没 阅读全文
posted @ 2017-08-11 09:44 apanda009 阅读(218) 评论(0) 推荐(0)
摘要:巧用 Integer.MAX_VALUE;来替换 true 阅读全文
posted @ 2017-08-05 17:52 apanda009 阅读(138) 评论(0) 推荐(0)
摘要:https://leetcode.com/submissions/detail/106698735/ 要求O(logN)的时间复杂度,想到用二分查找。如果中间元素大于其相邻后续元素,则中间元素左侧(包含该中间元素)必包含一个局部最大值。如果中间元素小于其相邻后续元素,则中间元素右侧必包含一个局部最大 阅读全文
posted @ 2017-06-20 22:15 apanda009 阅读(130) 评论(0) 推荐(0)