04 2015 档案
摘要:题目:Given a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioning ofs.For example, ...
阅读全文
摘要:题目: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 ...
阅读全文
摘要:题目:Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeati...
阅读全文
摘要:题目: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...
阅读全文
摘要:题目:Given a range [m, n] where 0 >>= 1; 8 n >>>= 1; 9 count++;10 }11 return m <<= count;12 }
阅读全文
摘要:题目: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...
阅读全文
摘要:题目: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...
阅读全文
摘要:题目: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...
阅读全文
摘要:这两个题,都是用bit operation解决的,但是第二个稍微tricky一点。先说第一个,我们利用XOR, 如果一个数字出现两次,那么在每一位上,两两抵消。唯独那个只出现一次的,没有另一半和它抵消了。。所以就剩下了。 1 public int singleNumber(int[] A) ...
阅读全文
摘要:题目:Given a string, find the length of the longest substring without repeating characters.For example, the longest substring without repeating letters ...
阅读全文
摘要:题目:Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.For exa...
阅读全文
摘要:题目: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...
阅读全文
摘要:题目:Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given"25525511135",return["25...
阅读全文
摘要:题目: 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...
阅读全文
摘要:题目: 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...
阅读全文
摘要:这题第一眼看到想到的是BFS。接着想到我需要一个queue来做BFS。之后,为了能一一对应的复制,还用到一个Map。对应新旧node。BUG: 就是我在复制新child node之前,就把旧child node添加到新的node的neighbors中了。 1 public Undirecte...
阅读全文