- 博客(511)
- 资源 (7)
- 收藏
- 关注
原创 leetcode 525. Contiguous Array
Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1.Example 1:Input: [0,1]Output: 2Explanation: [0, 1] is the longest contiguous subarray with
2017-08-18 16:33:54 380
原创 leetcode 474. Ones and Zeroes
In the computer world, use restricted resource you have to generate maximum benefit is what we always want to pursue.For now, suppose you are a dominator of m 0s and n 1s respectively. On the othe
2017-08-18 14:51:18 281
原创 leetcode 640. Solve the Equation
Solve a given equation and return the value of x in the form of string "x=#value". The equation contains only '+', '-' operation, the variable x and its coefficient.If there is no solution for
2017-08-17 20:22:50 1661
原创 leetcode 39. Combination Sum
Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen
2017-08-17 17:36:00 313
原创 leetcode 491. Increasing Subsequences
Given an integer array, your task is to find all the different possible increasing subsequences of the given array, and the length of an increasing subsequence should be at least 2 .Example:In
2017-08-17 14:57:25 250
原创 leetcode 235. Lowest Common Ancestor of a Binary Search Tree
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined betwee
2017-08-16 17:26:17 161
原创 leetcode 236. Lowest Common Ancestor of a Binary Tree
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes
2017-08-16 17:02:37 182
原创 leetcode 27. Remove Element
Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.
2017-08-16 14:18:31 231
原创 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.splicing的意思是:绞接( splice的现在分词 ); 捻接(两段绳子)也就是说把两个 sorte
2017-08-16 13:56:48 234
转载 0/1背包问题
P01: 01背包问题题目有N件物品和一个容量为V的背包。第i件物品的费用是c[i],价值是w[i]。求解将哪些物品装入背包可使价值总和最大。基本思路这是最基础的背包问题,特点是:每种物品仅有一件,可以选择放或不放。用子问题定义状态:即f[i][v]表示前i件物品恰放入一个容量为v的背包可以获得的最大价值。则其状态转移方程便是:f[i][v]=max{f[i
2017-08-15 17:30:12 455
原创 leetcode 416. Partition Equal Subset Sum
Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.Note:Each of the array
2017-08-15 17:21:35 289
原创 leetcode 660. Remove 9
Start from integer 1, remove any integer that contains 9 such as 9, 19, 29...So now, you will have a new integer sequence: 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, ...Given a positive integer n, you ne
2017-08-15 13:25:43 1087
原创 leetcode 215. Kth Largest Element in an Array
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.
2017-08-15 12:07:35 240
原创 leetcode 334. Increasing Triplet(三连) Subsequence
Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.Formally the function should:Return true if there exists i, j, k such that arr[i] ar
2017-08-14 17:03:32 269
原创 leetcode 380. Insert Delete GetRandom O(1)
Design a data structure that supports all following operations in average O(1) time.insert(val): Inserts an item val to the set if not already present.remove(val): Removes an item val from the
2017-08-14 14:38:32 232
原创 sql leetcode 182. Duplicate Emails
Write a SQL query to find all duplicate emails in a table named Person.+----+---------+| Id | Email |+----+---------+| 1 | a@b.com || 2 | c@d.com || 3 | a@b.com |+----+---------+For
2017-08-14 13:39:01 362
原创 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-1.
2017-08-14 13:11:58 1860
原创 leetcode 263. Ugly Number
Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly sinc
2017-08-13 14:50:49 183
原创 leetcode 191. Number of 1 Bits
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary representation 00000000
2017-08-13 14:33:43 325
原创 leetcode 458. Poor Pigs
Auto Saved.|||Type here...(Markdown is enabled)InstructionsThis question is currently in draft mode.If you feel the problem
2017-08-13 13:46:56 780
原创 leetcode 53. Maximum Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4],the contiguous subarray [4,-1,2,1] ha
2017-08-12 14:01:34 270
原创 leetcode 102. Binary Tree Level Order Traversal
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 2
2017-08-12 13:30:03 199
原创 leetcode 77. Combinations
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]
2017-08-12 13:05:13 437
原创 leetcode 59. Spiral Matrix II
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral(螺旋形的) order.For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4
2017-08-11 15:22:58 172
原创 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 order.You may assume no duplicates in the array.
2017-08-11 14:31:44 177
原创 leetcode 83. Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.这道题是简单题。public ListNode
2017-08-11 14:06:01 246
原创 leetcode 153. Find Minimum in Rotated Sorted Array
Suppose an array sorted in ascending order 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).Find the minimum element.You may as
2017-08-10 18:03:34 235
原创 leetcode 437. Path Sum III
You are given a binary tree in which each node contains an integer value.Find the number of paths that sum to a given value.The path does not need to start or end at the root or a leaf, but it
2017-08-10 17:25:49 374
原创 leetcode 593. Valid Square
Given the coordinates of four points in 2D space, return whether the four points could construct a square.The coordinate (x,y) of a point is represented by an integer array with two integers.E
2017-08-10 14:34:13 554
原创 leetcode 70. Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be a posi
2017-08-09 14:44:13 423
原创 leetcode 107. Binary Tree Level Order Traversal II
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree [3,9,20,null,null,15,
2017-08-09 13:09:21 230
原创 leetcode 231. Power of Two
Given an integer, write a function to determine if it is a power of two.判断一个整数 n 是否是 2 的乘方。之前做了Power of Three,再看这道题就是小case啦。public boolean isPowerOfTwo(int n) { return n>0&&1073741824%n==0;}
2017-08-09 12:46:48 213
原创 leetcode 352. Data Stream as Disjoint Intervals
Given a data stream input of non-negative integers a1, a2, ..., an, ..., summarize the numbers seen so far as a list of disjoint intervals.For example, suppose the integers from the data stream
2017-08-08 18:21:12 444
原创 leetcode 145. Binary Tree Postorder Traversal
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: Recursive solut
2017-08-08 15:25:10 302
原创 leetcode 326. Power of Three
Given an integer, write a function to determine if it is a power of three.Follow up:Could you do it without using any loop / recursion?这道题要求很简单,就是判断n是否是3的乘方。难点在于不能用循环和递归。(注意:1是3的乘方,因为1是3的0次方。)
2017-08-08 13:53:11 411
原创 leetcode 78. Subsets
Given a set of distinct integers, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets.For example,If nums = [1,2,3], a solution is:[ [3], [1],
2017-08-07 14:28:53 209
原创 leetcode 202. Happy Number
Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares
2017-08-07 13:31:51 191
原创 leetcode 611. Valid Triangle Number
Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle.Example 1
2017-08-07 10:52:22 409
原创 leetcode 309. Best Time to Buy and Sell Stock with Cooldown
Say you have an array for which the ith 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, buy on
2017-08-06 17:47:48 258
原创 leetcode 572. Subtree of Another Tree
Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a tree consists of a node in s and all of this no
2017-08-06 14:37:54 434
[数学建模方法与分析].(新西兰)Mark.M.Meerschaert.清晰PDF版
2017-09-15
有名的combobox下拉框插件压缩后的js版本
2016-09-23
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人