摘要: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode *mergeKLists(ve... 阅读全文
posted @ 2013-09-15 16:55 懒猫欣 阅读(141) 评论(0) 推荐(0)
摘要: Given two sorted integer arrays A and B, merge B into A as one sorted array. Note: You may assume that A has enough space to hold additional elements from B. The number of elements initialized in A and B are m and n respectively.class Solution {public: void merge(int A[], int m, int B[], int n) {... 阅读全文
posted @ 2013-09-15 15:54 懒猫欣 阅读(146) 评论(0) 推荐(0)
摘要: iven a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [6,5,7], [4,1,8,3]]The minimum path sum from top to bottom is 11 (i.e., 2 + 3 + 5 + 1 = 11). Note: Bonus point i... 阅读全文
posted @ 2013-09-15 15:41 懒猫欣 阅读(191) 评论(0) 推荐(0)
摘要: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class So... 阅读全文
posted @ 2013-09-15 14:30 懒猫欣 阅读(148) 评论(0) 推荐(0)
摘要: Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu... 阅读全文
posted @ 2013-09-15 11:21 懒猫欣 阅读(371) 评论(0) 推荐(0)
摘要: Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest substring is "b", with the length of 1.简 阅读全文
posted @ 2013-09-15 01:47 懒猫欣 阅读(159) 评论(0) 推荐(0)