上一页 1 ··· 7 8 9 10 11 12 13 14 下一页
摘要: Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.keypoints: 1 be familiar with use of pointer to pointer ** pre, no need for a dummy head node.2. when the container need erase or insert, it's probably a sign of using list instead of vector.3. when u 阅读全文
posted @ 2013-01-11 04:38 西施豆腐渣 阅读(144) 评论(0) 推荐(0) 编辑
摘要: There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).<uncompleted, do not pass all test cases.>class Solution {private: int len; int m; int n;public: double findMedianSortedArrays(int 阅读全文
posted @ 2013-01-10 08:18 西施豆腐渣 阅读(113) 评论(0) 推荐(0) 编辑
摘要: Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray[4,−1,2,1]has the largest sum =6.More practice:If you have figured out the O(n) solution, try coding another solution usi 阅读全文
posted @ 2013-01-10 05:35 西施豆腐渣 阅读(138) 评论(0) 推荐(0) 编辑
摘要: Depth-first traversalpreorder(node) if node == null then return visit(node) preorder(node.left) preorder(node.right) iterativePreorder(node) parentStack = empty stack while not parentStack.isEmpty() or node != null if node != null then parentStack.push(node) visit(node) ... 阅读全文
posted @ 2013-01-09 13:54 西施豆腐渣 阅读(186) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.1. recursive way./** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * ... 阅读全文
posted @ 2013-01-09 12:48 西施豆腐渣 阅读(136) 评论(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.m 阅读全文
posted @ 2013-01-09 07:14 西施豆腐渣 阅读(155) 评论(0) 推荐(0) 编辑
摘要: Write a function to find the longest common prefix string amongst an array of strings.reminders: 1. class Solution { public: string longestCommonPrefix(vector<string> &strs) { // Start typing your C/C++ solution below // DO NOT write int main() function // in this questio... 阅读全文
posted @ 2013-01-09 06:29 西施豆腐渣 阅读(160) 评论(0) 推荐(0) 编辑
摘要: Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word does not exist, return 0.Note:A word is defined as a character sequence consists of non-space characters only.For example,Givens="Hello Worl 阅读全文
posted @ 2013-01-09 06:04 西施豆腐渣 阅读(146) 评论(0) 推荐(0) 编辑
摘要: Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.my reminders: string is different vector, which can use position instead of iterator to assign a element. because string's element is char but vector is templete. also string can insert or o 阅读全文
posted @ 2013-01-09 05:37 西施豆腐渣 阅读(161) 评论(0) 推荐(0) 编辑
摘要: Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.Example 1:Given intervals[1,3],[6,9], insert and merge[2,5]in as[1,5],[6,9].Example 2:Given[1,2],[3,5],[6,7],[8 阅读全文
posted @ 2013-01-08 15:25 西施豆腐渣 阅读(120) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 下一页