自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(82)
  • 收藏
  • 关注

原创 Leetcode - 215.Kth Largest Element in an Array.

Problem Description : Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example, Given [3,2,1,5,6,4] and

2016-03-06 14:45:17 322

原创 Leetcode - 287. Find the Duplicate Number

Problem Description: Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one

2016-03-05 09:03:29 335

原创 Leetcode- 241.Different Ways to Add Parentheses

Problem Description : Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, -

2016-02-19 06:31:38 318

原创 Leetcode - 144. Binary Tree Traversal

Problem: Given a binary tree, return the preorder, inorder, postorder traversal of its nodes’ values.Preorder :Recursive :vector<int> preorderTraversal(TreeNode* root) { vector<int> res; help

2016-02-10 11:07:39 276

原创 Leetcode - 295. Find Median From Data Stream

Problem Description Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.Examples: [2,

2016-02-03 06:54:54 310

原创 Leetcode - 285.Inorder Successor in BST

Problem Description: Given a binary search tree and a node in it, find the in-order successor of that node in the BST.Note: If the given node has no in-order successor in the tree, return null.Analysi

2016-02-02 03:52:40 377

原创 Leetcode - 266. Palindrome Permutation

Problem Description: Given a string, determine if a permutation of the string could form a palindrome.For example, “code” -> False, “aab” -> True, “carerac” -> True. Hint: Consider the palindromes

2016-01-26 10:16:06 408

原创 Leetcode - 146. LRU Cache

Problem Description: Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positiv

2016-01-25 06:24:14 235

原创 Leetcode - 261. Graph Valid Tree

Problem description: Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree.For example

2016-01-25 03:41:00 457

原创 Leetcode -229. Majority Element

Problem Description: Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.Analysis: Moore Voting Algorith

2016-01-24 04:22:22 215

原创 Leetcode - 137. Single Number II

Problem Description: Given an array of integers, every element appears three times except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implem

2016-01-23 05:31:50 236

原创 Leetcode-259. 3 Sum Smaller

Problem Description: Given an array of n integers nums and a target, find the number of index triplets i, j, k with 0 <= i < j < k < n that satisfy the condition nums[i] + nums[j] + nums[k] < target.F

2016-01-23 03:51:47 331

原创 Leetcode- 1. Two Sum

Problem description: 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 t

2016-01-19 12:31:43 279

原创 Leetcode - 213. House Robber II

Problem Description : After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This time, all houses at this plac

2016-01-19 03:49:53 246

原创 Leetcode - 97.Interleaving String

Problem description: Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example, Given: s1 = “aabcc”, s2 = “dbbca”,When s3 = “aadbbcbcac”, return true. When s3 = “aad

2016-01-18 05:27:21 229

原创 Leetcode-54.Spiral Matrix

Problem Description: Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example, Given the following matrix: [ [ 1, 2, 3 ], [ 4, 5, 6 ]

2016-01-17 10:24:06 358

原创 Leetcode-252.Meeting Rooms

Problem Description:Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],…] (si < ei), determine if a person could attend all meetings.For example, Given [[0, 30

2016-01-16 04:35:00 399

原创 Leetcode-246.Strobogrammatic Number

Problem Description: A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).Write a function to determine if a number is strobogrammatic. The number

2016-01-15 11:14:11 355

原创 Leetcode-245.Shortest Word Distance

Problem Description:This is a follow up of Shortest Word Distance. The only difference is now you are given the list of words and your method will be called repeatedly many times with different paramet

2016-01-15 10:54:13 299

原创 Leetcode-231.Flatten 2D Vector

Problem Description:  Implement an iterator to flatten a 2d vector.For example, Given 2d vector =[ [1,2], [3], [4,5,6] ] By calling next repeatedly until hasNext returns false, the order of

2016-01-15 04:52:31 283

原创 Leetcode-241.Different Ways to Add Parentheses

Problem Description: Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - an

2016-01-13 23:22:19 252

原创 Leetcode-33.Search in Rotated Sorted Array.

Problem description: Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the

2016-01-13 04:13:28 248

原创 Leetcode-159.Longest Substring with At Most Two Distinct Characters

Problem DescriptionGiven a string, find the length of the longest substring T that contains at most 2 distinct characters.For example, Given s = “eceba”,T is “ece” which its length is 3. Analysis: We

2016-01-10 04:11:10 382

原创 Leetcode-14. Longest Common Prefix

Problem Description: Write a function to find the longest common prefix string amongst an array of strings.Analysis: It’s an easy problem. First pieces of code is regular solution. I try to use Trie

2016-01-08 11:20:14 373

原创 Leetcode-65.Valid Number

Problem Description: Validate if a given string is numeric.Some examples: “0” => true ” 0.1 ” => true “abc” => false “1 a” => false “2e10” => trueAnalysis: This link provides a nicely systemati

2016-01-07 05:53:36 238

原创 Leetcode-25.Reverse Nodes in k-Group

Problem Description: Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of nodes is not a multiple of k then left-out nodes in the end sho

2016-01-04 12:26:03 266

原创 Leetcode-23.Merge k Sorted Lists

Problem Description: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Analysis : The idea is straightforward, keep merging the remained lists until th

2016-01-04 04:53:26 223

原创 Leetcode-10.Regular Expression Matching

Problem Description: Implement regular expression matching with support for ‘.’ and ‘*’ ‘.’ Matches any single character. ‘*’ Matches zero or more of the preceding element.The matching should cover

2016-01-04 00:46:29 194

原创 Leetcode-4.Median of Two Sorted Arrays

Problem Description : There are two sorted arrays nums1 and nums2 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)).This li

2016-01-03 05:20:45 214

原创 Leetcode-52.N-Queens

Problem: 1. return the all configuration the vector of the chessborad 2. return the amount of of distinct solutionAnalysis: The idea is using DFS search with backtracking in recursive. We use a 1D

2016-01-02 04:31:13 183

原创 Leetcode-210.Course Schedule

Problem Description: There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which i

2015-12-31 23:43:14 186

原创 Leetcode-163.Missing Ranges

Problem Description:Given a sorted integer array where the range of elements are [lower, upper] inclusive, return its missing ranges.For example, given [0, 1, 3, 50, 75], lower = 0 and upper = 99, retu

2015-12-31 03:49:33 285

原创 Leetcode-166.Fraction to Recurring Decimal

Problem Description: Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating, enclose the repeating part

2015-12-30 12:54:37 176

原创 Leetcode-151.Reverse Words in a String

Problem Description: Given an input string, reverse the string word by word.For example, Given s = ” the sky is blue “, return “blue is sky the”.Analysis: This is probably by far the most common

2015-12-30 03:42:26 205

原创 Leetcode-187.Repeated DNA Sequences

Problem Description: 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 identify repeated sequences w

2015-12-29 11:54:51 244

原创 Leetcode-127.Word Ladder

Problem description : Given two words (beginWord and endWord), and a dictionary’s word list, find the length of shortest transformation sequence from beginWord to endWord, such that:Only one letter c

2015-12-29 04:53:19 276

原创 Leetcode-134.Gas Station

Problem Description: There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel fro

2015-12-28 06:16:26 227

原创 Leetcode-224.Basic Calculator

Problem Description: Implement a basic calculator to evaluate a simple expression string. The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative

2015-12-28 04:11:57 220

原创 Leetcode-227.Basic Calculator II

Problem Description: Implement a basic calculator to evaluate a simple expression string. The expression string contains only non-negative integers, +, -, *, / operators and empty spaces . The intege

2015-12-28 00:47:23 218

原创 Leetcode-28.Implement strStr()

Problem description: Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Analysis: A classical problem with different ways to s

2015-12-27 05:56:56 342

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除