A self-dividing number is a number that is divisible by every digit it contains. For example,…
分类:LeetCode
一个易于理解的C++全排列(permutation)实现
通常我们用这两条语句可以得到一个数组的全排列: sort(nums.begin(),nums.end()); //调用next_permutation求全排列的时候必须先给容器排序 do{ get_pirnt(nums)…
Leetcode - Linked List Random Node
My code: /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * List…
[LeetCode] Find Peak Element 求数组的局部峰值
A peak element is an element that is greater than its neighbors. Given an input array nums, where&…
[LeetCode] Majority Element 求众数
Given an array of size n, find the majority element. The majority element is the element that appe…
[LeetCode] Encode and Decode TinyURL 编码和解码精简URL地址
Note: This is a companion problem to the System Design problem: Design TinyURL. TinyUR…
[LeetCode] Degree of an Array 数组的度
Given a non-empty array of non-negative integers nums, the degree of this array is defin…
204. Count Primes
Count the number of prime numbers less than a non-negative number, n. Example: Input: 10 Output: 4 Explanation…
[Leetcode] Simplify Path 化简路径
Simplify Path Given an absolute path for a file (Unix-style), simplify it. For example, path = "/home/", =>…
LeetCode | Gray Code(格雷码)
The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negat…
LeetCode | Next Permutation(下一个排列)
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of nu…
Leetcode. 数组排序之后相邻数的最大差值
问题 给定一个整型数组 arr, 返回排序后的相邻两数的最大差值. 例如: arr = [9, 3, 1, 10], 如果排序, 结果为[1, 3, 9, 10], 9和3的差为最大差值, 故返回6. 分析 如果要做到时…