Leetcode

Leetcode

2 已关注
30篇博文
• Leetcode：713.Subarray Product Less Than K

题目描述： 题目：Your are given an array of positive integers nums.Count and print the number of (contiguou...

2017-11-04 11:00
41
• Leetcode：121. Best Time to Buy and Sell Stock

题目： Say you have an array for which the ith element is the price of a given stock on day i.If you w...

2017-11-05 11:41
25
• Leetcode：27.Remove Element

题目：Given an array and a value, remove all instances of that value in-place and return the new length...

2017-11-06 10:34
31
• Leetcode：36.Valid Sudoku 初始化数独数组是否合法判断

Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be p...

2017-11-06 11:04
37
• Leetcode：349. Intersection of Two Arrays

Given two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1...

2017-11-10 20:32
24
• Leetcode：112. Path Sum （求Tree中是否存在路径的和等于给定值）

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all...

2017-11-10 21:04
19
• Leetcode：111. Minimum Depth of Binary Tree（求Tree的最小的深度）

Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the short...

2017-11-10 21:42
17
• Leetcode：350. Intersection of Two Arrays II 求两个数组的交集

Given two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1...

2017-11-11 13:12
22
• Leetcode：475. Heaters （利用二分binary search）

题目： Winter is coming! Your first job during the contest is to design a standard heater with fixed w...

2017-11-11 14:41
24
• Leetcode：167. Two Sum II - Input array is sorted 求数组中的两个数的和等于给定值，求这两个数的下标

Given an array of integers that is already sorted in ascending order, find two numbers such that the...

2017-11-11 15:06
29
• Leetcode：367 Valid Perfect Square（是否为平方数）

Given a positive integer num, write a function which returns True if num is a perfect square else Fa...

2017-11-11 15:29
30
• Leetcode：628. Maximum Product of Three Numbers

Given an integer array, find three numbers whose product is maximum and output the maximum product.E...

2017-11-12 11:48
26
• Leetcode14

编写一个函数来查找字符串数组中最长的公共前缀字符串。package genius.wangyuxian.Algorithms;public class WYX14 { public stati...

2017-10-18 13:17
31
• Leetcode3 求最长子串的长度

思路： 1.借助HashMap一个一个put进去。 2.put进去的元素会在后续进行判断，如果map里面已经有了当前put的元素，那么更新j，j为当前j和当前字符串出现的键的值加1的最大值。 3...

2017-10-18 14:34
32
• LeetCode58 返回最后一个字符串的最后一个单词的长度

最开始，我的代码在开始输入”a “这种情况下通不过一些用例，知道最后我发现运用s = s.trim()可以解决这个问题，去除字符串开头和结尾的所有的空格。package genius...

2017-10-20 11:13
26
• LeetCode231 判断是否为2的幂

正解： return ((n & (n-1))==0 && n>0);我的错误答案：package genius.wyx.Algorithms;public class WYX231 { pu...

2017-10-20 12:53
28
• Leetcode 22 Generate Parentheses

Given n pairs of parentheses, write a function to generate all combinations of well-formed parenthes...

2017-10-26 13:07
26
• Leetcode 520 Detect Capital

Given a word, you need to judge whether the usage of capitals in it is right or not.We define the us...

2017-10-26 13:34
30
• Leetcode100：Same Tree 判断两棵树是否完全相等

Given two binary trees, write a function to check if they are equal or not.Two binary trees are cons...

2017-10-26 14:02
63
• Leetcode 657 Judge Route Circle回到原点

Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot m...

2017-10-26 15:10
31