IncredibleThings

导航

2018年10月2日 #

LeetCode - Find All Anagrams in a String

摘要: 这道题先想到了用hash存一下p出现的字符和个数,然后遍历s来做。但超时了: 第一个就是定义的hash数组长度是256,因为ascii码的长度是256位的,所以每一位的索引表示一个字符的计数值。另外就是在窗口的部分,分别用两个指针表示窗口的左边界和右边界。还有用count作为一个计数值,它的含义是窗 阅读全文

posted @ 2018-10-02 19:42 IncredibleThings 阅读(155) 评论(0) 推荐(0) 编辑

LeetCode - Copy List with Random Pointer

摘要: 如果要copy一个带有random pointer的list,主要的问题就是有可能这个random指向的位置还没有被copy到,所以解决方法都是多次扫描list。 第一种方法,就是使用HashMap来坐,HashMap的key存原始pointer,value存新的pointer。 第一遍,先不cop 阅读全文

posted @ 2018-10-02 11:52 IncredibleThings 阅读(77) 评论(0) 推荐(0) 编辑

LeetCode - Serialize and Deserialize Binary Tree

摘要: 无法直接传入int因为它是primitive type, changes made to it will not be visible outside the function scope. 阅读全文

posted @ 2018-10-02 10:09 IncredibleThings 阅读(75) 评论(0) 推荐(0) 编辑