04 2015 档案

摘要:题目:Given a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioning ofs.For example, ... 阅读全文
posted @ 2015-04-30 23:58 GoNuts 阅读(140) 评论(0) 推荐(0) 编辑
摘要:题目:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?思路:We can use two pointers: walker and ... 阅读全文
posted @ 2015-04-29 08:27 GoNuts 阅读(108) 评论(0) 推荐(0) 编辑
摘要:题目:Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeati... 阅读全文
posted @ 2015-04-20 09:56 GoNuts 阅读(226) 评论(0) 推荐(0) 编辑
摘要:题目:Given a 2d grid map of'1's (land) and'0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjace... 阅读全文
posted @ 2015-04-19 05:37 GoNuts 阅读(157) 评论(0) 推荐(0) 编辑
摘要:题目:Given a range [m, n] where 0 >>= 1; 8 n >>>= 1; 9 count++;10 }11 return m <<= count;12 } 阅读全文
posted @ 2015-04-18 08:03 GoNuts 阅读(370) 评论(0) 推荐(0) 编辑
摘要:题目:Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL... 阅读全文
posted @ 2015-04-12 01:29 GoNuts 阅读(91) 评论(0) 推荐(0) 编辑
摘要:题目:There areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You have a car with an unlimited gas tank and it costsco... 阅读全文
posted @ 2015-04-12 01:24 GoNuts 阅读(183) 评论(0) 推荐(0) 编辑
摘要:题目:Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:Ele... 阅读全文
posted @ 2015-04-10 12:03 GoNuts 阅读(137) 评论(0) 推荐(0) 编辑
摘要:这两个题,都是用bit operation解决的,但是第二个稍微tricky一点。先说第一个,我们利用XOR, 如果一个数字出现两次,那么在每一位上,两两抵消。唯独那个只出现一次的,没有另一半和它抵消了。。所以就剩下了。 1 public int singleNumber(int[] A) ... 阅读全文
posted @ 2015-04-10 06:59 GoNuts 阅读(129) 评论(0) 推荐(0) 编辑
摘要:题目:Given a string, find the length of the longest substring without repeating characters.For example, the longest substring without repeating letters ... 阅读全文
posted @ 2015-04-10 05:16 GoNuts 阅读(127) 评论(0) 推荐(0) 编辑
摘要:题目:Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.For exa... 阅读全文
posted @ 2015-04-10 04:01 GoNuts 阅读(118) 评论(0) 推荐(0) 编辑
摘要:题目:Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.For exa... 阅读全文
posted @ 2015-04-10 01:44 GoNuts 阅读(116) 评论(0) 推荐(0) 编辑
摘要:题目:Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given"25525511135",return["25... 阅读全文
posted @ 2015-04-09 12:06 GoNuts 阅读(135) 评论(0) 推荐(0) 编辑
摘要:题目: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a sin... 阅读全文
posted @ 2015-04-09 02:19 GoNuts 阅读(156) 评论(0) 推荐(0) 编辑
摘要:题目: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stoppin... 阅读全文
posted @ 2015-04-06 00:51 GoNuts 阅读(206) 评论(0) 推荐(0) 编辑
摘要:这题第一眼看到想到的是BFS。接着想到我需要一个queue来做BFS。之后,为了能一一对应的复制,还用到一个Map。对应新旧node。BUG: 就是我在复制新child node之前,就把旧child node添加到新的node的neighbors中了。 1 public Undirecte... 阅读全文
posted @ 2015-04-04 12:34 GoNuts 阅读(111) 评论(0) 推荐(0) 编辑