
Algorithm
FrankJingle
这个作者很懒,什么都没留下…
展开
-
【LeetCode】(136)Single Number (Easy)
题目Single Number Total Accepted: 83386 Total Submissions: 184587My SubmissionsQuestion Solution Given an array of integers, every element appears twice except for one. Fin原创 2015-08-22 21:06:58 · 261 阅读 · 0 评论 -
【LeetCode】20_Valid Parentheses
题目Valid Parentheses Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct原创 2015-08-19 11:27:46 · 316 阅读 · 0 评论 -
【LeetCode】88_Merge Sorted Array
题目Merge Sorted Array Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is gre原创 2015-08-19 14:17:30 · 316 阅读 · 0 评论 -
【LeetCode】217_Contains Duplicate
题目Contains Duplicate Total Accepted: 28558 Total Submissions: 79085My SubmissionsQuestion Solution Given an array of integers, find if the array contains any duplicates.原创 2015-08-19 21:09:54 · 332 阅读 · 0 评论 -
【LeetCode】191_Number of 1 Bits
题目Number of 1 Bits Total Accepted: 43643 Total Submissions: 115129My SubmissionsQuestion Solution Write a function that takes an unsigned integer and returns the number o原创 2015-08-19 22:39:30 · 315 阅读 · 0 评论 -
【LeetCode】78_Subsets
题目SubseGiven a set of distinct integers, nums, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain dupli原创 2015-08-19 17:24:54 · 304 阅读 · 0 评论 -
【LeetCode】34_Search for a Range
题目Search for a RangeGiven 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 order of O(原创 2015-08-19 16:07:24 · 364 阅读 · 0 评论 -
【LeetCode】50_Pow(x, n)
题目Pow(x, n)Implement pow(x, n).解析题目看似很简单,需要注意的地方在于,要考虑到n为负数和0的情况。第二,不能使用递归,要用迭代,递归会导致堆栈溢出。如果你以为这样就好了,例如我的如下代码class Solution {public: double myPo原创 2015-08-19 18:49:32 · 406 阅读 · 0 评论 -
【LeetCode】118_Pascal's Triangle
题目Pascal's Triangle Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,原创 2015-08-19 20:29:56 · 231 阅读 · 0 评论 -
【LeetCode】125_Valid Palindrome
题目Valid Palindrome Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is原创 2015-08-18 22:19:51 · 312 阅读 · 0 评论 -
【LeetCode】16_3Sum Closest
题目3Sum ClosestGiven an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume th原创 2015-08-18 16:27:13 · 330 阅读 · 0 评论 -
【LeetCode】(233)Number of Digit One (Medium)
题目Number of Digit One Total Accepted: 7360 Total Submissions: 36604My SubmissionsQuestion Solution Given an integer n, count the total number of digit 1 appearing in all原创 2015-08-25 20:32:34 · 362 阅读 · 0 评论 -
【Leetcode】(5)Longest Palindromic Substring(Medium)
题目Longest Palindromic Substring Total Accepted: 65384 Total Submissions: 316489My SubmissionsQuestion Solution Given a string S, find the longest palindromic substring in原创 2015-08-27 21:50:11 · 337 阅读 · 0 评论 -
【LeetCode】(3)Longest Substring Without Repeating Characters(Medium)
题目Longest Substring Without Repeating Characters Total Accepted: 87434 Total Submissions: 432439My SubmissionsQuestion Solution Given a string, find the length of the lon原创 2015-08-27 14:18:02 · 363 阅读 · 0 评论 -
【LeetCode】122.Best Time to Buy and Sell Stock II
题目:Say you have an array for which theith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, bu原创 2015-08-15 16:38:34 · 331 阅读 · 0 评论 -
【LeetCode]1.Two Sum
题目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 numbers such that they add up to the target,原创 2015-08-16 20:41:18 · 373 阅读 · 0 评论 -
【LeetCode】15_3Sum
题目Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triple原创 2015-08-17 22:16:10 · 318 阅读 · 0 评论 -
【LeetCode】18_4Sum
题目4Sum Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target原创 2015-08-18 17:59:06 · 363 阅读 · 0 评论 -
【LeetCode】2_Add Two Numbers
题目Add Two Numbers Total Accepted: 81118 Total Submissions: 398160My SubmissionsQuestion Solution You are given two linked lists representing two non-negative numbers. T原创 2015-08-18 20:56:43 · 313 阅读 · 0 评论 -
【LeetCode】119_Pascal's Triangle II
题目Pascal's Triangle II Total Accepted: 49035 Total Submissions: 166823My SubmissionsQuestion Solution Given an index k, return the kth row of the Pascal's triangle.For原创 2015-08-19 21:02:40 · 360 阅读 · 0 评论 -
【LeetCode】169_Majority Element
题目Majority Element Total Accepted: 56172 Total Submissions: 158142My SubmissionsQuestion Solution Given an array of size n, find the majority element. The majority elemen原创 2015-08-19 21:27:10 · 224 阅读 · 0 评论 -
【LeetCode】(94)Binary Tree Inorder Traversal(Easy)
题目Binary Tree Inorder Traversal Total Accepted: 78083 Total Submissions: 214829My SubmissionsQuestion Solution Given a binary tree, return the inorder traversal of its no原创 2015-08-20 16:44:07 · 268 阅读 · 0 评论 -
【LeetCode】(263)Ugly Number(Easy)
题目Ugly Number Total Accepted: 4084 Total Submissions: 12843My SubmissionsQuestion Solution Write a program to check whether a given number is an ugly number.Ugly number原创 2015-08-21 19:09:27 · 292 阅读 · 0 评论 -
【LeetCode】(66)Plus One (Easy)
题目Plus One Total Accepted: 58836 Total Submissions: 194801My SubmissionsQuestion Solution Given a non-negative number represented as an array of digits, plus one to the n原创 2015-08-21 22:01:12 · 347 阅读 · 0 评论 -
【LeetCode】(67)Add Binary (Easy)
题目Add Binary Total Accepted: 52390 Total Submissions: 212953My SubmissionsQuestion Solution Given two binary strings, return their sum (also a binary string).For exampl原创 2015-08-21 22:54:13 · 339 阅读 · 0 评论 -
【LeetCode】(172)Factorial Trailing Zeroes(Easy)
题目Factorial Trailing Zeroes Total Accepted: 32870 Total Submissions: 112610My SubmissionsQuestion Solution Given an integer n, return the number of trailing zeroes in n!.原创 2015-08-21 23:11:53 · 292 阅读 · 0 评论 -
【LeetCode】(63)Unique Paths II(Medium)
题目Unique Paths II Total Accepted: 42440 Total Submissions: 151936My SubmissionsQuestion Solution Follow up for "Unique Paths":Now consider if some obstacles are added t原创 2015-08-22 19:12:56 · 315 阅读 · 0 评论 -
【LeetCode】(242)Valid Anagram(Easy)
题目Valid Anagram Total Accepted: 15164 Total Submissions: 44518My SubmissionsQuestion Solution Given two strings s and t, write a function to determine if t is an anagram原创 2015-08-22 09:57:26 · 321 阅读 · 0 评论 -
【LeetCode】(58)Length of Last Word(Easy)
题目Length of Last Word Total Accepted: 59959 Total Submissions: 218191My SubmissionsQuestion Solution Given a string s consists of upper/lower-case alphabets and empty spa原创 2015-08-22 16:20:24 · 298 阅读 · 0 评论 -
【LeetCode】(55)Jump Game(Medium)
题目Jump Game Total Accepted: 52275 Total Submissions: 194395My SubmissionsQuestion Solution Given an array of non-negative integers, you are initially positioned at the fi原创 2015-08-22 15:09:22 · 9191 阅读 · 0 评论 -
【LeetCode】(7)Reverse Integer(Easy)
题目Reverse Integer Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321解析新建一个y,每次把x最后以为赋给y,这样循环就好了原创 2015-08-21 18:33:47 · 272 阅读 · 0 评论 -
【LeetCode】237_Delete Node in a Linked List
题目Delete Node in a Linked List Total Accepted: 19324 Total Submissions: 43206My SubmissionsQuestion Solution Write a function to delete a node (except the tail) in a sing原创 2015-08-19 21:50:33 · 301 阅读 · 0 评论 -
【LeetCode】258_Add Digits
题目Add Digits Total Accepted: 5413 Total Submissions: 11941My SubmissionsQuestion Solution Given a non-negative integer num, repeatedly add all its digits until the resu原创 2015-08-19 22:15:49 · 341 阅读 · 0 评论 -
【LeetCode】(104)Maximum Depth of Binary Tree(Easy)
题目Maximum Depth of Binary Tree Total Accepted: 79538 Total Submissions: 176206My SubmissionsQuestion Solution Given a binary tree, find its maximum depth.The maximum de原创 2015-08-20 15:52:58 · 304 阅读 · 0 评论 -
【LeetCode】(100)Same Tree(Easy)
题目Same TreeGiven two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have原创 2015-08-20 16:08:14 · 321 阅读 · 0 评论 -
【LeetCode】(144)Binary Tree Preorder Traversal(Easy)
题目Binary Tree Preorder Traversal Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3原创 2015-08-20 16:53:55 · 241 阅读 · 0 评论 -
【LeetCode】(112)Path Sum(Easy)
题目Path Sum Total Accepted: 65733 Total Submissions: 221541My SubmissionsQuestion Solution Given a binary tree and a sum, determine if the tree has a root-to-leaf path suc原创 2015-08-21 14:58:01 · 319 阅读 · 0 评论 -
【LeetCode】(113)Path Sum II(Medium)
题目Path Sum II Total Accepted: 52790 Total Submissions: 198801My SubmissionsQuestion Solution Given a binary tree and a sum, find all root-to-leaf paths where each path's原创 2015-08-21 17:48:59 · 342 阅读 · 0 评论 -
【LeetCode】(202)Happy Number(Easy)
题目Happy Number Total Accepted: 26154 Total Submissions: 82078My SubmissionsQuestion Solution Write an algorithm to determine if a number is "happy".A happy number is a原创 2015-08-21 19:34:28 · 371 阅读 · 0 评论 -
【LeetCode】(204)Count Primes(Easy)
题目Count Primes Total Accepted: 27781 Total Submissions: 139375My SubmissionsQuestion Solution Description:Count the number of prime numbers less than a non-negative原创 2015-08-25 19:49:13 · 439 阅读 · 0 评论