2015年8月28日

[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 阅读(138) 评论(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 阅读(225) 评论(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 阅读(126) 评论(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 阅读(105) 评论(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 阅读(132) 评论(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 阅读(119) 评论(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 阅读(118) 评论(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 阅读(101) 评论(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 阅读(78) 评论(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 阅读(89) 评论(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 阅读(137) 评论(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 阅读(113) 评论(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 阅读(100) 评论(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 阅读(159) 评论(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 阅读(158) 评论(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 阅读(209) 评论(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 阅读(169) 评论(0) 推荐(0) 编辑

导航