05 2015 档案
摘要:题目:Given a stringsand a dictionary of wordsdict, add spaces insto construct a sentence where each word is a valid dictionary word.Return all such poss...
阅读全文
摘要:题目:Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].思...
阅读全文
摘要:题目I:Reverse a singly linked list思路:建立三个指针,一个用来维护链表头,另外两个再循环中,维护head的前一位和保存反转的后一位。 逐个反转,首先反转前两个,然后把前两个看成是一个,继续循环反转下去。代码:public class Solution { p...
阅读全文
摘要:题目:The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the total num...
阅读全文
摘要:题目:Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the or...
阅读全文
摘要:题目:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2-...
阅读全文
摘要:题目:Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted arraynums=[1,1,1,2,2,3],Your function should...
阅读全文
摘要:Given an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"Corner Cases:Did you con...
阅读全文