题目如下: Given a positive integer N, return the number of positive integers less than or equal to N that have at least 1 repeated digit. Example 1: Input: 20 Output: 1 Explanation: The only positive number (<= 20) with at least 1 repeated digit is 11. E…
Given a positive integer N, return the number of positive integers less than or equal to N that have at least 1 repeated digit. Example 1: Input: 20 Output: 1 Explanation: The only positive number (<= 20) with at least 1 repeated digit is 11. Example…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 DFS 日期 题目地址:https://leetcode.com/problems/numbers-with-same-consecutive-differences/ 题目描述 Return all non-negative integers of length N such that the absolute difference between…
题目如下: Return all non-negative integers of length N such that the absolute difference between every two consecutive digits is K. Note that every number in the answer must not have leading zeros except for the number 0 itself. For example, 01 has one l…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.com/problems/complement-of-base-10-integer/ 题目描述 Every non-negative integer N has a binary representation. For example, 5 can be represented as "101&qu…
题目如下: Every non-negative integer N has a binary representation.  For example, 5 can be represented as "101" in binary, 11 as "1011" in binary, and so on.  Note that except for N = 0, there are no leading zeroes in any binary representa…
[2]Add Two Numbers (2018年12月23日,review) 链表的高精度加法. 题解:链表专题:https://www.cnblogs.com/zhangwanying/p/9797184.html [7]Reverse Integer (2018年12月23日, review) 给了一个32位的整数,返回它的reverse后的整数.如果reverse后的数超过了整数的范围,就返回 0. Example 1: Input: 123 Output: 321 Example 2:…
[10]Regular Expression Matching [17]Letter Combinations of a Phone Number [22]Generate Parentheses (2019年2月13日) 给了一个N,生成N对括号的所有情况的字符串. n = 3 [ "((()))", "(()())", "(())()", "()(())", "()()()" ] 题解:dfs生成. c…
题目如下: An integer has sequential digits if and only if each digit in the number is one more than the previous digit. Return a sorted list of all the integers in the range [low, high] inclusive that have sequential digits. Example 1: Input: low = 100,…
[LeetCode]129. Sum Root to Leaf Numbers 解题报告(Python) 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/sum-root-to-leaf-numbers/description/ 题目描述: Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a numbe…
[LeetCode]165. Compare Version Numbers 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.me/ 题目地址:https://leetcode.com/problems/compare-version-numbers/description/ 题目描述: Compare two version numbers version1 and vers…
[LeetCode]738. Monotone Increasing Digits 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/monotone-increasing-digits/description/ 题目描述: Given a non-negative integer N, find th…
[LeetCode]718. Maximum Length of Repeated Subarray 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/maximum-length-of-repeated-subarray/description/ 题目描述: Given two integer arr…
[LeetCode]201. Bitwise AND of Numbers Range 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/bitwise-and-of-numbers-range/description/ 题目描述: Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers i…
[LeetCode]386. Lexicographical Numbers 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.me/ 题目地址:https://leetcode.com/problems/lexicographical-numbers/description/ 题目描述: Given an integer n, return 1 - n in lexicogra…
[LeetCode]402. Remove K Digits 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/remove-k-digits/description/ 题目描述: Given a non-negative integer num represented as a string, rem…
[LeetCode]423. Reconstruct Original Digits from English 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/reconstruct-original-digits-from-english/description/ 题目描述: Given a non-empty string containing an out-of-order English representatio…
[LeetCode]91. Decode Ways 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/decode-ways/description/ 题目描述: A message containing letters from A-Z is being encoded to numbers usin…
[LeetCode]880. Decoded String at Index 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/decoded-string-at-index/description/ 题目描述: An encoded string S is given. To find and wri…
[LeetCode]468. Validate IP Address 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.me/ 题目地址:https://leetcode.com/problems/validate-ip-address/description/ 题目描述: Write a function to check whether an input string is…
[LeetCode]306. Additive Number 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.me/ 题目地址:https://leetcode.com/problems/additive-number/description/ 题目描述: Additive number is a string whose digits can form additive se…
[LeetCode]831. Masking Personal Information 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.me/ 题目地址:https://leetcode.com/problems/masking-personal-information/description/ 题目描述: We are given a personal information…
全排列问题.经常使用的排列生成算法有序数法.字典序法.换位法(Johnson(Johnson-Trotter).轮转法以及Shift cursor cursor* (Gao & Wang)法. [题目] Given a collection of numbers, return all possible permutations. For example, [1,2,3] have the following permutations: [1,2,3], [1,3,2], [2,1,3], [2…
[题目] Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example, [1,1,2] have the following unique permutations: [1,1,2], [1,2,1], and [2,1,1]. [解析] 题意:求一个数组的全排列.与[LeetCode]Permutations 解题报告 不同的是…
[1]Two Sum (2018年11月9日,k-sum专题,算法群衍生题) 给了一个数组 nums, 和一个 target 数字,要求返回一个下标的 pair, 使得这两个元素相加等于 target . 题解:我这次最大范围的优化代码, hash-table + one pass,时间复杂度 O(N),空间复杂度 O(N).重点在于动态找,一边生成hash-table的同时去找答案,不是先生成hash-table再开始找答案. //这种类似 hash 的能用 unordered_map 就不要…
题目如下: Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so on. Each time a player picks a number, that number will not be available f…
题目如下: 解题思路:这题看起来和[leetcode]448. Find All Numbers Disappeared in an Array很相似,但是有几点不同:一是本题的输入存在负数,二是没有约定输入元素的最大值.那么,怎么可以把本题转换成448题的场景呢?首先,我们可以求出输入数组nums中所有正整数的数量,记为p,那么显然能得出这个结论:1 <=answer < p+1.然后,我们可以通过交换把所有值不在这个区间内的元素值移动到数组的后半部分.记nums前半部分[0:length]…
[LeetCode]376. Wiggle Subsequence 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/wiggle-subsequence/description/ 题目描述: A sequence of numbers is called a wiggle sequence if the differences betw…
[LeetCode]120. Triangle 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址https://leetcode.com/problems/triangle/description/ 题目描述: Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjac…
[LeetCode]299. Bulls and Cows 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/bulls-and-cows/description/ 题目描述: You are playing the following Bulls and Cows game with your friend: You write down…