摘要: iteratively and recursively time: O(n) space: O(n) time: O(n) space: O(n) 感觉还是这个,因为虽然看起来不用什么数据结构,但是实际上recursion本身在space里就是一个stack 阅读全文
posted @ 2016-11-04 12:40 哇呀呀..生气啦~ 阅读(71) 评论(0) 推荐(0)
摘要: 经典的套环问题,后面的套环题变式都是用Array的index来代表pointer以此判断是否重复element之类的。。 快慢指针相遇。 time: O(n) space: O(1) 阅读全文
posted @ 2016-11-04 11:56 哇呀呀..生气啦~ 阅读(72) 评论(0) 推荐(0)
摘要: 和那个换球的题很像,这里连换都省了,因为最后剩下的那些无所谓了。。 time: O(n) space: O(1) java public class Solution { public int removeElement(int[] nums, int val) { if (nums.length 阅读全文
posted @ 2016-11-04 11:51 哇呀呀..生气啦~ 阅读(57) 评论(0) 推荐(0)
摘要: recursively 比较直白,重点是每次传入要比较的2个,然后魔爪要伸向下下层。。 iteratively好像比较麻烦,不想用多余空间的话,用LIST代替QUEUE,每次一层之后夹逼比较。 否则要N/2的多余空间来做专门用于比较的LIST 阅读全文
posted @ 2016-11-04 08:58 哇呀呀..生气啦~ 阅读(70) 评论(0) 推荐(0)
摘要: 看一个培训面试的视频,就使用这个题当例题的,我觉得我做的比面试里的人好多了,可实际上紧张的时候我的大脑是不能被信任的,所以。。。 java public class Solution { public String reverseVowels(String s) { if (s.length() 阅读全文
posted @ 2016-11-04 08:15 哇呀呀..生气啦~ 阅读(75) 评论(0) 推荐(0)
摘要: 主要是看怎么分别对待Node总数是奇数还是偶数,其实也没什么区别的。。 好恨你。 让我心神不定。 阅读全文
posted @ 2016-11-04 08:07 哇呀呀..生气啦~ 阅读(62) 评论(0) 推荐(0)
摘要: 今天做的都是E难度的。。懒得写。 这道感觉不是E难度。。 判断是否能SHIFT是使用 俩字母之间相差是一样的,或者+了26,因为Z的下一个是A。 然后好像其实也没什么别的值得说的,总结下就是,按长度先分类,然后同样长度的要再按SHIFT分类。 这题怎么都不像E难度的。。 Java public cl 阅读全文
posted @ 2016-11-04 07:54 哇呀呀..生气啦~ 阅读(115) 评论(0) 推荐(0)
摘要: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For 阅读全文
posted @ 2016-11-04 04:39 哇呀呀..生气啦~ 阅读(98) 评论(0) 推荐(0)
摘要: You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. Given n, find the total number 阅读全文
posted @ 2016-11-04 04:17 哇呀呀..生气啦~ 阅读(514) 评论(0) 推荐(0)
摘要: You are given a binary tree in which each node contains an integer value. Find the number of paths that sum to a given value. The path does not need t 阅读全文
posted @ 2016-11-04 03:52 哇呀呀..生气啦~ 阅读(790) 评论(0) 推荐(0)