上一页 1 ··· 48 49 50 51 52 53 54 55 56 ··· 80 下一页
摘要: Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3,4], [2,3],... 阅读全文
posted @ 2015-01-20 22:59 匡子语 阅读(242) 评论(0) 推荐(0)
摘要: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.思路:题目看上去好像很难,但实际上很简单,递归做就行,每次找到左右子树对应的子链表... 阅读全文
posted @ 2015-01-18 20:17 匡子语 阅读(197) 评论(0) 推荐(0)
摘要: Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, retu... 阅读全文
posted @ 2015-01-18 19:55 匡子语 阅读(224) 评论(0) 推荐(0)
摘要: Sort a linked list using insertion sort.思路:用插入排序对链表排序。插入排序是指每次在一个排好序的链表中插入一个新的值。注意:把排好序的部分和未排序的部分完全分开,指针不要有交叉。 即不会通过->next 重叠class Solution {public: ... 阅读全文
posted @ 2015-01-18 19:33 匡子语 阅读(206) 评论(0) 推荐(0)
摘要: Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After re... 阅读全文
posted @ 2015-01-17 21:50 匡子语 阅读(176) 评论(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 single ... 阅读全文
posted @ 2015-01-17 21:10 匡子语 阅读(244) 评论(0) 推荐(0)
摘要: Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level and al... 阅读全文
posted @ 2015-01-17 17:16 匡子语 阅读(207) 评论(0) 推荐(0)
摘要: A peak element is an element that is greater than its neighbors.Given an input array wherenum[i] ≠ num[i+1], find a peak element and return its index.... 阅读全文
posted @ 2015-01-16 20:58 匡子语 阅读(281) 评论(0) 推荐(0)
摘要: Given a list of non negative integers, arrange them such that they form the largest number.For example, given[3, 30, 34, 5, 9], the largest formed num... 阅读全文
posted @ 2015-01-16 17:36 匡子语 阅读(272) 评论(0) 推荐(0)
摘要: Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct ... 阅读全文
posted @ 2015-01-16 14:32 匡子语 阅读(167) 评论(0) 推荐(0)
上一页 1 ··· 48 49 50 51 52 53 54 55 56 ··· 80 下一页