08 2015 档案

[LeetCode] 34 - Search for a Range
摘要:Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the ord... 阅读全文

posted @ 2015-08-31 14:25 tuituji 阅读(140) 评论(0) 推荐(0)

[LeetCode] 35 - Search Insert Position
摘要:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or... 阅读全文

posted @ 2015-08-31 11:05 tuituji 阅读(147) 评论(0) 推荐(0)

[LeetCode] 23 - Merge k Sorted Lists
摘要:Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity./** * Definition for singly-linked list. * struct List... 阅读全文

posted @ 2015-08-29 16:47 tuituji 阅读(131) 评论(0) 推荐(0)

[LeetCode] 22 - Generate Parentheses
摘要:Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:"((()))... 阅读全文

posted @ 2015-08-29 15:22 tuituji 阅读(131) 评论(0) 推荐(0)

[LeetCode] 16 - 3Sum Closest
摘要:Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integers. You m... 阅读全文

posted @ 2015-08-29 14:37 tuituji 阅读(194) 评论(0) 推荐(0)

[LeetCode] 15 - 3Sum
摘要:Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:Elemen... 阅读全文

posted @ 2015-08-29 13:53 tuituji 阅读(187) 评论(0) 推荐(0)

[LeetCode] 232 - Implement Queue using Stacks
摘要:Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front o... 阅读全文

posted @ 2015-08-28 21:46 tuituji 阅读(149) 评论(0) 推荐(0)

[LeetCode] 260 - Single Number III
摘要:Given an array of numbersnums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements t... 阅读全文

posted @ 2015-08-28 21:37 tuituji 阅读(242) 评论(0) 推荐(0)

[LeetCode] 268 - Missing Number
摘要:Given an array containingndistinct numbers taken from0, 1, 2, ..., n, find the one that is missing from the array.For example,Givennums=[0, 1, 3]retur... 阅读全文

posted @ 2015-08-28 21:10 tuituji 阅读(131) 评论(0) 推荐(0)

[LeetCode] 187 - Repeated DNA Sequences
摘要:All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to ... 阅读全文

posted @ 2015-08-28 11:52 tuituji 阅读(113) 评论(0) 推荐(0)

[LeetCode] 238 - Product of Array Except Self
摘要:Given an array ofnintegers wheren> 1,nums, return an arrayoutputsuch thatoutput[i]is equal to the product of all the elements ofnumsexceptnums[i].Solv... 阅读全文

posted @ 2015-08-28 11:44 tuituji 阅读(142) 评论(0) 推荐(0)

[LeetCode] 199 - Binary Tree Right Side View
摘要:Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.For exampl... 阅读全文

posted @ 2015-08-28 11:41 tuituji 阅读(130) 评论(0) 推荐(0)

[LeetCode] 240 - Search a 2D Matrix II
摘要:Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted in asc... 阅读全文

posted @ 2015-08-28 11:19 tuituji 阅读(130) 评论(0) 推荐(0)

[LeetCode] 169 - Majority Element
摘要:Given an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.You may assume that the arr... 阅读全文

posted @ 2015-08-28 11:17 tuituji 阅读(107) 评论(0) 推荐(0)

[LeetCode] 28 - Implement strStr()
摘要:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.class Solution {public: ... 阅读全文

posted @ 2015-08-28 11:14 tuituji 阅读(89) 评论(0) 推荐(0)

[LeetCode] 27 - Remove Element
摘要:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't mat... 阅读全文

posted @ 2015-08-28 11:11 tuituji 阅读(97) 评论(0) 推荐(0)

[LeetCode] 14 - Longest Common Prefix
摘要:Write a function to find the longest common prefix string amongst an array of strings.class Solution { public: string longestCommonPrefix(vect... 阅读全文

posted @ 2015-08-28 11:09 tuituji 阅读(148) 评论(0) 推荐(0)

[LeetCode] 9 - Palindrome Number
摘要:Determine whether an integer is a palindrome. Do this without extra space.class Solution { public: bool isPalindrome(int x) { if (x... 阅读全文

posted @ 2015-08-28 11:05 tuituji 阅读(124) 评论(0) 推荐(0)

[LeetCode] 7 - Reverse Integer
摘要:Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321class Solution {public: int reverse(int x) { in... 阅读全文

posted @ 2015-08-28 11:03 tuituji 阅读(108) 评论(0) 推荐(0)

[LeetCode] 2 - Add Two Numbers
摘要: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-08-28 10:59 tuituji 阅读(173) 评论(0) 推荐(0)

[LeetCode] 21 - Merge Two Sorted Lists
摘要: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./** * Def... 阅读全文

posted @ 2015-08-28 10:54 tuituji 阅读(170) 评论(0) 推荐(0)

[LeetCode] 26 - Remove Duplicates from Sorted Array
摘要:Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space for a... 阅读全文

posted @ 2015-08-28 10:48 tuituji 阅读(218) 评论(0) 推荐(0)

[LeetCode] 20 - Valid Parentheses
摘要:Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct ... 阅读全文

posted @ 2015-08-28 10:42 tuituji 阅读(182) 评论(0) 推荐(0)

导航