上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 25 下一页
摘要: Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of the two partitions.For example,Given 1->4->3->2->5->2 and x = 3,return 1->2->2-> 阅读全文
posted @ 2013-08-15 17:00 冰点猎手 阅读(140) 评论(0) 推荐(0)
摘要: Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BANC".Note:If there is no such window in S that covers all characters in T, return the 阅读全文
posted @ 2013-08-14 23:07 冰点猎手 阅读(266) 评论(0) 推荐(0)
摘要: iven a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at any point in time. 动态规划: grid[i][j] += min(grid[i-1][j], grid[i][j-1])class Solution {public: int mi... 阅读全文
posted @ 2013-08-14 21:51 冰点猎手 阅读(166) 评论(0) 推荐(0)
摘要: Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the grid.For example,There is one obstacle in the middle of a 3x3 grid as illustrated below.[ [0,0,0], [ 阅读全文
posted @ 2013-08-14 21:43 冰点猎手 阅读(186) 评论(0) 推荐(0)
摘要: 3Sum Closest 3Sum 4Sum Add Binary Add Two Numbers Anagrams Balanced Binary Tree Best Time to Buy and Sell Stock III Best Time to Buy and Sell Stock II 阅读全文
posted @ 2013-08-14 21:43 冰点猎手 阅读(315) 评论(0) 推荐(0)
摘要: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).How many possible 阅读全文
posted @ 2013-08-14 21:31 冰点猎手 阅读(315) 评论(0) 推荐(0)
摘要: Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL. 巨没劲的一道题,当k>length 时,我以为origin list 不动就行,结果好些case过不了,看了别人的代码才知道要 k%= length 真心想不通为什么,也懒得弄这种恶心的东西。面试遇到这种题目直接问面试官这 阅读全文
posted @ 2013-08-14 20:57 冰点猎手 阅读(166) 评论(0) 推荐(0)
摘要: Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. You may not modify the values in the list, only nodes itself can be changed. /** * Definition 阅读全文
posted @ 2013-08-14 10:08 冰点猎手 阅读(155) 评论(0) 推荐(0)
摘要: Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255.11.135", "255.255.111.35"]. (Order does not matter) class Solution {public: bool check(string s){ if(atoi(s.c_str() 阅读全文
posted @ 2013-08-12 23:17 冰点猎手 阅读(158) 评论(0) 推荐(0)
摘要: Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1 3 3 2 1 \ / / / \ \ 3 2 1 1 3 2 / / ... 阅读全文
posted @ 2013-08-12 22:26 冰点猎手 阅读(191) 评论(0) 推荐(0)
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 25 下一页