
leetcode
文章平均质量分 65
MrOneside
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
326. Power of Three解法
题目链接:https://leetcode.com/problems/power-of-three/ Given an integer, write a function to determine if it is a power of three. 有两种解法:非递归和递归,分别如下: class Solution { public: bool isPowerOfThree(i原创 2017-02-06 14:04:34 · 345 阅读 · 0 评论 -
304. Range Sum Query 2D - Immutable
问题链接:点击打开链接 Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2). The above rectangle原创 2017-02-10 15:13:41 · 268 阅读 · 0 评论 -
315. Count of Smaller Numbers After Self
问题链接:https://leetcode.com/problems/count-of-smaller-numbers-after-self/?tab=Description You are given an integer array nums and you have to return a new counts array. The counts array has the pro转载 2017-02-28 20:03:24 · 479 阅读 · 0 评论 -
300. Longest Increasing Subsequence
问题链接:点击打开链接 Given an unsorted array of integers, find the length of longest increasing subsequence. For example, Given [10, 9, 2, 5, 3, 7, 101, 18], The longest increasing subsequence is [2,原创 2017-02-10 18:10:48 · 195 阅读 · 0 评论 -
306. Additive Number
问题链接:点击打开链接 原文链接:http://blog.youkuaiyun.com/sbitswc/article/details/50191729 Additive number is a string whose digits can form additive sequence. A valid additive sequence should contain at least t转载 2017-02-10 18:43:01 · 202 阅读 · 0 评论 -
289: Game of Life
问题链接:点击打开链接 According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970." Give转载 2017-02-20 11:37:09 · 291 阅读 · 0 评论 -
287. 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 dup原创 2017-02-20 20:53:33 · 232 阅读 · 0 评论 -
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() -- Return whet原创 2017-03-01 19:15:28 · 189 阅读 · 0 评论 -
263. Ugly Number
问题链接:https://leetcode.com/problems/ugly-number/?tab=Description Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only in原创 2017-02-21 18:50:16 · 286 阅读 · 0 评论 -
220. Contains Duplicate III
问题链接:点击打开链接 Given an array of integers, find out whether there are two distinct indices i and j in the array such that the absolute difference betweennums[i] and nums[j] is at most t and the ab原创 2017-03-01 20:44:39 · 491 阅读 · 0 评论 -
264. Ugly Number II
问题链接:https://leetcode.com/problems/ugly-number-ii/?tab=Description Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For原创 2017-02-21 19:37:53 · 297 阅读 · 0 评论 -
313. Super Ugly Number
问题链接:https://leetcode.com/problems/super-ugly-number/?tab=Description Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all prime factors are in原创 2017-02-21 20:15:36 · 354 阅读 · 0 评论 -
149. Max Points on a Line
原文链接:https://leetcode.com/problems/max-points-on-a-line/?tab=Description Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 要求:求出平面n个点中,最多共线的点数。原创 2017-03-02 13:15:37 · 370 阅读 · 0 评论 -
307. Range Sum Query - Mutable
问题链接:点击打开链接 Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. The update(i, val) function modifies nums by updating the element at index i原创 2017-02-14 22:03:37 · 223 阅读 · 0 评论 -
365. Water and Jug Problem
问题链接:点击打开链接 题目: You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to determine whether it is possible to measure exactl转载 2017-02-15 17:28:17 · 242 阅读 · 0 评论 -
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原创 2017-02-15 20:49:21 · 225 阅读 · 0 评论 -
Largest Rectangle in Histogram
Find the largest rectangular area possible in a given histogram where the largest rectangle can be made of a number of contiguous bars. For simplicity, assume that all bars have same width and the wid原创 2017-03-06 11:24:56 · 415 阅读 · 0 评论 -
303. Range Sum Query - Immutable
问题链接:点击打开链接 Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: Given nums = [-2, 0, 3, -5, 2, -1] sumRange(0, 2) -> 1 sumRange(2原创 2017-02-10 10:28:55 · 310 阅读 · 0 评论 -
299. Bulls and Cows
问题链接:点击打开链接 You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you原创 2017-02-09 22:22:38 · 220 阅读 · 0 评论 -
318. Maximum Product of Word Lengths
题目链接:https://leetcode.com/problems/maximum-product-of-word-lengths/ Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share原创 2017-02-07 16:54:49 · 193 阅读 · 0 评论 -
322. Coin Change
原文链接:http://blog.youkuaiyun.com/baidu_23318869/article/details/50891006 问题链接:https://leetcode.com/problems/coin-change/ 代码如下: [cpp] view plain copy // CPP class Sol转载 2017-02-07 21:18:21 · 267 阅读 · 0 评论 -
367. Valid Perfect Square
问题链接:https://leetcode.com/problems/valid-perfect-square/ 原文:http://www.cnblogs.com/guoguolan/p/5619443.html Given a positive integer num, write a function which returns True if num is a perfect转载 2017-02-07 21:28:09 · 259 阅读 · 0 评论 -
319. Bulb Switcher
原文链接:http://blog.youkuaiyun.com/baidu_23318869/article/details/50386323 问题链接:https://leetcode.com/problems/bulb-switcher/ [cpp] view plain copy // CPP class Solutio原创 2017-02-07 17:26:30 · 247 阅读 · 0 评论 -
357. Count Numbers with Unique Digits
题目链接:https://leetcode.com/problems/count-numbers-with-unique-digits/ Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x n. Example: Given n = 2, return 91.转载 2017-02-16 17:06:57 · 270 阅读 · 0 评论 -
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 su原创 2017-02-17 11:08:22 · 249 阅读 · 0 评论 -
324. Wiggle Sort II
题目链接:https://leetcode.com/problems/wiggle-sort-ii/ 我的解题思路:先用快排从小到大排序,然后分别将前半段数据和后半段数据依次插入,若有中间数据,则放在最后即是题目要求的格式。 public class Solution { public void wiggleSort(int[] nums) { if(num原创 2017-02-08 20:08:25 · 196 阅读 · 0 评论 -
349. Intersection of Two Arrays
问题链接:https://leetcode.com/problems/intersection-of-two-arrays/ Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return原创 2017-02-09 10:53:14 · 221 阅读 · 0 评论 -
350. Intersection of Two Arrays II
问题链接:https://leetcode.com/problems/intersection-of-two-arrays-ii/ Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], retu原创 2017-02-09 12:43:22 · 199 阅读 · 0 评论 -
268. Missing Number
问题链接:https://leetcode.com/problems/missing-number/ Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example, Given n原创 2017-02-09 15:25:19 · 181 阅读 · 0 评论 -
273. Integer to English Words
问题链接:https://leetcode.com/problems/integer-to-english-words/?tab=Description Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1.原创 2017-02-09 16:14:49 · 199 阅读 · 0 评论 -
278. First Bad Version
问题链接:https://leetcode.com/problems/first-bad-version/?tab=Description You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your pr原创 2017-02-09 16:41:32 · 243 阅读 · 0 评论 -
279. Perfect Squares
问题链接:https://leetcode.com/problems/perfect-squares/ Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. For example, g原创 2017-02-09 17:05:08 · 183 阅读 · 0 评论 -
283. Move Zeroes
问题链接:https://leetcode.com/problems/move-zeroes/?tab=Description Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero e原创 2017-02-09 17:31:47 · 185 阅读 · 0 评论 -
290. Word Pattern
问题链接:https://leetcode.com/problems/word-pattern/?tab=Description Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a原创 2017-02-09 21:31:51 · 170 阅读 · 0 评论 -
292. Nim Game
问题链接:https://leetcode.com/problems/nim-game/ 转载来源:http://blog.youkuaiyun.com/fly_yr/article/details/50071367 You are playing the following Nim Game with your friend: There is a heap of stones on the t转载 2017-02-09 21:55:53 · 266 阅读 · 0 评论 -
Container With Most Watert
题意:有n个相当于水桶的隔板,求使用两个隔板和底部x轴所能组成的水桶可以装载的最大容量。 第一种方法:两层遍历,第一层从0遍历到n-2,第二层从i+1遍历到n-1,每次求得(j-i)*(Math.min(height【i】,height【j】))与max比较,使max总是保存最大值。 缺点:需要n*n时间 第二种方法:线性时间,两个指针分别从0、n-1开始向中间靠拢,直到左指针不小于原创 2017-04-05 10:34:32 · 306 阅读 · 0 评论