- 博客(57)
- 收藏
- 关注
原创 LeetCode.507 Perfect Number
题目:We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself. Now, given an integer n, write a function that returns true when it
2017-11-28 20:36:59 182
原创 LeetCode.441 Arranging Coins (经典数列求和应用)
题目:You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins.Given n, find the total number of full staircase rows that can be fo
2017-11-28 11:16:01 229
原创 LeetCode.728 Self Dividing Numbers
题目:A self-dividing number is a number that is divisible by every digit it contains.For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0.Also,
2017-11-28 10:35:46 253
原创 LeetCode.368 Largest Divisible Subset(经典DP问题)
题目:Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or Sj % Si = 0.If there are multiple
2017-11-27 13:04:39 201
原创 LeetCode.215 Kth Largest Element in an Array 找出k个最大的(*****经典必备题*****)
题目: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 k = 2, return 5.Note...
2017-11-26 23:15:31 155
原创 LeetCode.735 Asteriod Collision
题目:We are given an array asteroids of integers representing asteroids in a row.For each asteroid, the absolute value represents its size, and the sign represents its direction (positive mean
2017-11-26 21:11:41 628
原创 LeetCode.224 Basic Calculator
题目: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 integers
2017-11-26 17:18:49 276
转载 算术表达式转成后缀表达式
package datastructure;public class Postfix { /** * 转为后缀表达式: * 1、如果是"("直接压入栈。 * 2、如果是")",依次从栈弹出运算符加到postfix的末尾,直到遇到"("; * 3、如果是运算符,比较扫描到的运算符,和栈顶的运算符。如果扫描到的运算符优先级 * 高
2017-11-26 11:38:30 1005
原创 LeetCode.402 Remove K Digits
题目:Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible.Note:The length of num is less than 10002 a
2017-11-25 20:13:32 210
原创 LeetCode.456 Pattern
题目:Given a sequence of n integers a1, a2, ..., an, a 132 pattern is a subsequence ai, aj, ak such that i j k and ai < ak j. Design an algorithm that takes a list of n numbers as input
2017-11-23 23:47:33 233
原创 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 of queue.peek() -- Get the front eleme
2017-11-23 15:36:34 181
原创 LeetCode.636 Exclusive Time of Functions
题目:Given the running logs of n functions that are executed in a nonpreemptive single threaded CPU, find the exclusive time of these functions.Each function has a unique id, start from 0 to n
2017-11-23 15:18:02 303
原创 LeetCode.394 Decode String
题目:Given an encoded string, return it's decoded string.The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note
2017-11-21 20:43:28 189
原创 LeetCode.385 Mini Parser
题目:Given a nested list of integers represented as a string, implement a parser to deserialize it.Each element is either an integer, or a list -- whose elements may also be integers or other
2017-11-21 16:10:03 174
原创 LeetCode.341 Flatten Nested List Iterator
题目:Given a nested list of integers, implement an iterator to flatten it.Each element is either an integer, or a list -- whose elements may also be integers or other lists.Example 1:Giv
2017-11-21 15:19:01 157
原创 LeetCode.331 Verify Preorder Serialization of a Binary Tree
题目:One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as
2017-11-21 09:37:56 108
原创 LeetCode.225 Implement Stack using Queues
题目:Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get the top element.empty() -- Re
2017-11-19 17:04:40 137
原创 LeetCode.150 Calculate Reverse Polish Notation
题目:Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2"
2017-11-19 15:50:53 169
原创 LeetCode.145 Binary Tree Postorder Tranversal
题目:Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1].Note: Recurs
2017-11-18 22:34:47 149
原创 LeetCode.144 Binary Tree Preorder Traversal
题目:Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,2,3].Note: Recu
2017-11-18 21:24:43 96
原创 LeetCode.103 Binary Tree Zigzag Level Order Traversal
题目:Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Give
2017-11-18 20:35:58 87
原创 LeetCode.94 Binary Tree Inorder Traversal
题目:Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,3,2].Note: Recur
2017-11-18 20:34:02 129
原创 LeetCode.155 Min Stack
题目:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top(
2017-11-17 22:20:46 93
原创 LeetCode.496(503、556) Next Greater Element I && II && III
题目:You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corresponding place
2017-11-16 21:59:30 127
原创 LeetCode.682 Baseball Game
题目:You're now a baseball game point recorder.Given a list of strings, each string can be one of the 4 following types:Integer (one round's score): Directly represents the number of poi
2017-11-16 21:17:22 699 2
原创 LeetCode.55(45) Jump Game && II (经典的动态规划问题)
题目:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if you...
2017-11-15 16:01:52 751
原创 LeetCode.697 Degree of an Array
题目:Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements.Your task is to find the smallest possible
2017-11-14 21:49:25 111
原创 LeetCode.717 1-bit and 2-bit Characters
题目:We have two special characters. The first character can be represented by one bit 0. The second character can be represented by two bits (10 or 11). Now given a string represented by se
2017-11-14 19:31:01 311
原创 LeetCode.76 Minimum Window Substring
题目:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is
2017-11-14 15:59:57 112
原创 LeetCode.724 Find Pivot Index
题目:Given an array of integers nums, write a method that returns the "pivot" index of this array.We define the pivot index as the index where the sum of the numbers to the left of the
2017-11-13 17:26:21 239
原创 LeetCode.718 Maximum Length of Repeated Subarray(经典DP问题)
题目:Given two integer arrays A and B, return the maximum length of an subarray that appears in both arrays.Example 1:Input:A: [1,2,3,2,1]B: [3,2,1,4,7]Output: 3Explanation: The rep
2017-11-13 16:54:33 277
原创 LeetCode.281 Find the Duplicate Number
题目: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 duplicate n
2017-11-12 23:36:59 177
原创 LeetCode.41 First Missing Positive
题目:Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses
2017-11-12 23:34:43 98
原创 LeetCode.676 Implement Magic Dictionary
题目:Implement a magic directory with buildDict, and search methods.For the method buildDict, you'll be given a list of non-repetitive words to build a dictionary.For the method search,
2017-11-12 17:54:02 420
原创 LeetCode.720 Longest Word in Dictionary
题目:Given a list of strings words representing an English Dictionary, find the longest word in words that can be built one character at a time by other words in words. If there is more than o
2017-11-12 16:02:40 1479
原创 LeetCode.690 Employee Importance
题目:You are given a data structure of employee information, which includes the employee's unique id, his importance value and his directsubordinates' id. For example, employee 1 is the lead
2017-11-10 17:03:59 466
原创 LeetCode.648 Replace Words
题目:In English, we have a concept called root, which can be followed by some other words to form another longer word - let's call this word successor. For example, the root an, followed by ot
2017-11-10 11:36:32 261
原创 LeetCode.599 Minimum Index Sum of Two Lists (经典:哈希表对字符串去重和List与数组间的转换)
题目:Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings. You need to help them find out their common intere
2017-11-09 20:52:57 223
转载 Java中hashcode方法
转载:http://www.cnblogs.com/dolphin0520/ 哈希表这个数据结构想必大多数人都不陌生,而且在很多地方都会利用到hash表来提高查找效率。在Java的Object类中有一个方法:1public native int hashCode(); 根据这个方法的声明
2017-11-09 20:20:27 165
原创 LeetCode.594 Longest Harmonious Subsequence
题目:We define a harmonious array is an array where the difference between its maximum value and its minimum value is exactly 1.Now, given an integer array, you need to find the length of its
2017-11-09 18:47:35 117
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人