作者: 负雪明烛 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…
[LeetCode]659. Split Array into Consecutive Subsequences 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/split-array-into-consecutive-subsequences/description/ 题目描述: You are g…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 preSum + 字典 日期 题目地址:https://leetcode.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list/ 题目描述 Given the head of a linked list, we repeatedly delete consecutive sequ…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 脑筋急转弯 日期 题目地址:https://leetcode.com/problems/moving-stones-until-consecutive/ 题目描述 Three stones are on a number line at positions a, b, and c. Each turn, you pick up a stone at…
题目如下: 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 the head of a linked list, we repeatedly delete consecutive sequences of nodes that sum to 0 until there are no such sequences. After doing so, return the head of the final linked list.  You may return any such answer. (Note that in the e…
题目如下: Three stones are on a number line at positions a, b, and c. Each turn, you pick up a stone at an endpoint (ie., either the lowest or highest position stone), and move it to an unoccupied position between those endpoints.  Formally, let's say th…
题目如下: 解题思路:本题可以维护三个字典,dic_1保存没有组成序列的单元素,dic_2保存组成了包含两个元素的序列中的较大的元素,dic_3保存组成了包括三个或者三个以上元素的序列中的最大值.因为合法的序列至少要三个元素,解题的关键是要使得dic_2和dic_1的元素尽快满足条件.对于任意一个还没有加入字典的元素,加入字典的优先级从高到低排序分别是dic_2 > dic_1 > dic_3,即优先匹配dic_2,接下来匹配dic_1,再就是dic_3,如果三个都不满足,说明在目前条件下市落…
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 leading…