数字
文章平均质量分 57
帘外雨
学生一枚
展开
-
Leetcode 357. Count Numbers with Unique Digits
问题描述 Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Example: Given n = 2, return 91. (The answer should be the total numbers in the range of 0 ≤原创 2017-06-30 15:59:54 · 161 阅读 · 0 评论 -
LeetCode:442. Find All Duplicates in an Array
Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.Could you do it without extra space原创 2017-09-07 16:06:20 · 198 阅读 · 0 评论 -
LeetCode:406. Queue Reconstruction by Height
Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and k is the number of people in front of this p原创 2017-09-07 18:22:33 · 218 阅读 · 0 评论 -
LeetCode:526. Beautiful Arrangement
Suppose you have N integers from 1 to N. We define a beautiful arrangement as an array that is constructed by these N numbers successfully if one of the following is true for the ith position (1 <= i <原创 2017-09-07 20:43:15 · 287 阅读 · 0 评论 -
LeetCode:445. Add Two Numbers II
You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and return it原创 2017-09-15 19:46:29 · 206 阅读 · 0 评论 -
LeetCode:260. Single Number III
Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. For example: Given nums = [1原创 2017-09-09 17:31:21 · 220 阅读 · 0 评论 -
去哪儿2017编程题
问题:对于每个测试实例,要求输出大于n的下一个对称数字。 分析:最小的对称数字必然是改变靠近对称轴的数字,因此对于输入的数字可以分成以下2种: 1)对称轴左边的数字大于对应位置的右边数字,此时直接将对称轴左边的数字对称到右边即可: 3840 -> 3883; 342 -> 343; 2)对称轴左边的数字小于或者等于对应位置的右边数字,此时,最小的对称数字必然是将对称轴左边的第原创 2017-09-26 15:03:52 · 421 阅读 · 0 评论 -
LeetCode 667. Beautiful Arrangement II
Given two integers n and k, you need to construct a list which contains n different positive integers ranging from 1 to n and obeys the following requirement: Suppose this list is [a1, a2, a3, … , an],原创 2017-09-01 20:54:23 · 728 阅读 · 0 评论 -
665. Non-decreasing Array
Given an array with n integers, your task is to check if it could become non-decreasing by modifying at most 1 element.We define an array is non-decreasing if array[i] <= array[i + 1] holds for every i原创 2017-09-01 21:59:01 · 485 阅读 · 0 评论 -
LeetCode:384. Shuffle an Array
Discuss Pick One <!-- @END Action Button--> <div class="question-description"> <p></p><p>Shuffle a set of numbers without dup原创 2017-09-14 21:25:01 · 359 阅读 · 0 评论 -
LeetCode: 479. Largest Palindrome Product
Find the largest palindrome made from the product of two n-digit numbers. Since the result could be very large, you should return the largest palindrome mod 1337.Example: Input: 2 Output: 987 Explanat原创 2017-09-06 21:49:47 · 1284 阅读 · 0 评论 -
Leetcode 343. Integer Break
问题描述 Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For example, given n转载 2017-06-30 17:42:14 · 194 阅读 · 0 评论 -
Leetcode 338 Counting Bits
问题描述 Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array. Example: For n原创 2017-06-30 20:42:01 · 231 阅读 · 0 评论 -
Leetcode 279. 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, given n = 12, return 3 because 12 = 4 + 4 + 4; give原创 2017-07-04 11:07:25 · 179 阅读 · 0 评论 -
Leetcode:621. Task Scheduler
Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks.Tasks could be done without original order. Each task could be原创 2017-09-04 21:23:03 · 211 阅读 · 0 评论 -
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: In原创 2017-09-04 21:38:09 · 215 阅读 · 0 评论 -
LeetCode: 581. Shortest Unsorted Continuous Subarray
Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too. You need to find t原创 2017-09-05 14:21:22 · 178 阅读 · 0 评论 -
LeetCode: Add to List 414. Third Maximum Number
Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).Example 1: Input: [3, 2, 1]Outpu原创 2017-09-06 17:23:14 · 200 阅读 · 0 评论 -
LeetCode:204. Count Primes
Description: Count the number of prime numbers less than a non-negative number, n.Credits:Special thanks to @mithmatt for adding this problem and creating all test cases. 题意:输出小于n的素数(质数)的数目。(《编程之转载 2017-09-06 18:41:20 · 177 阅读 · 0 评论 -
LeetCode:462. Minimum Moves to Equal Array Elements II
Given a non-empty integer array, find the minimum number of moves required to make all array elements equal, where a move is incrementing a selected element by 1 or decrementing a selected element by 1原创 2017-09-11 10:49:50 · 214 阅读 · 0 评论