摘要: bit manipulation 总结 bit manipulation 总结 326. The power of three 第一个方法,是用n%3 检查n是否能被3整除,如果不行则可以直接退出。如果可以,拿n/3,直到n == 1 的时候,证明n一定是3^n。 第二个方法,base:10的时候, 阅读全文
posted @ 2017-12-06 04:52 nina阿瑶 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 120. Triangle 我的解法用了一个二维数组,这样比较浪费空间。O(n*n) 但是标准答案自底向上,一是不需要进行特别判断,二是可以覆盖数组,则只需要O(n)的空间大小。 他山之石: 64. Minimun Path Sum 和上一题思路基本一致,采用了上一题的思路,只用了一个1d arra 阅读全文
posted @ 2017-12-06 02:37 nina阿瑶 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 位运算 x&x-1 zero out the least significant 1 The first solution is to use the popCount method which could count the 1 bits for one specific number. The 阅读全文
posted @ 2017-12-05 22:05 nina阿瑶 阅读(159) 评论(0) 推荐(0) 编辑
摘要: Tree 102 Binary Tree Level Order Traversal 就是一个dfs,控制dfs每一层node数目的方法,用一个for循环,在进入for循环之前记录栈中的node树,以此作为for循环的次数。 106 Construct Binary Tree from Inorde 阅读全文
posted @ 2017-11-30 05:53 nina阿瑶 阅读(270) 评论(0) 推荐(0) 编辑
摘要: component component component:用户自己定义的元素 component:用户自己定义的元素 遇到自己定义的component Welcom,React会将它的属性(name)作为对象传递给组建Welcom,即{name='Sara'} eg:components名称必须以 阅读全文
posted @ 2017-11-27 23:49 nina阿瑶 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 173. Binary Search Tree Iterator 每次做到这道题都忘记怎么做。用一个栈来保存。 在这边用了DFS inorder 的顺序保存的数据。 要学习的点: 标准答案里是采用的另一种inorder 的变形,首先所有的left side node push进去,然后每pop出一个 阅读全文
posted @ 2017-11-22 23:41 nina阿瑶 阅读(299) 评论(0) 推荐(0) 编辑
摘要: Arrays.sort() & Collections.sort() Collections 是集合的工具类,Collections.sort用于对象集合按照用户自定义的规则进行排序(常用于对list进行排序) Arrays.sort 可以用于对象数组按照用户自定义规则排序。 eg: 本题中将字符串 阅读全文
posted @ 2017-11-19 12:27 nina阿瑶 阅读(586) 评论(0) 推荐(0) 编辑
摘要: HashMap 718. Maximun Length of Repeated Subarray 动态规划: 用lookUp[][]来记录,双层循环嵌套,保证每一种情况都考虑到。由于是连续的,所以不能用siegel的动归。 Binary Search (超时) 穷举,将所有的x长度的string一一 阅读全文
posted @ 2017-11-17 05:00 nina阿瑶 阅读(162) 评论(0) 推荐(0) 编辑
摘要: react: component and views : produce html abd add them on a page( in the dom) ES6 const: ES6 syntax, declare a variable. And which means it won't chan 阅读全文
posted @ 2017-11-15 23:55 nina阿瑶 阅读(116) 评论(0) 推荐(0) 编辑