【leetcode】402. Remove K Digits】的更多相关文章

[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…
题目如下: 解题思路:我的方法是从头开始遍历num,对于任意一个num[i],在[i+1~len(num)-1]区间内找出离num[i]最近并且小于num[i]的数num[j],如果j-i <= k的话表示num[j]可以被删除,同时记k -= 1:如果找不到num[j]或者j-i > k则表示不能被删除.如果num遍历完成,但是k>0的话,把num最后k个字符删除,即为最终结果. 代码如下: class Solution(object): def getNearbyMin(self,d…
402. Remove K Digits https://www.cnblogs.com/grandyang/p/5883736.html https://blog.csdn.net/fuxuemingzhu/article/details/81034522 https://blog.csdn.net/qq508618087/article/details/52584133 题目的要求是删除k个字符,在保证原字符串字符相对位置不变的情况下获得最小的数字. 一个贪心的思想,维护一个单调递增的栈.只…
[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]373. Find K Pairs with Smallest Sums 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/find-k-pairs-with-smallest-sums/description/ 题目描述: You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k…
[LeetCode]692. Top K Frequent Words 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/top-k-frequent-words/description/ 题目描述: Given a non-empty list of words, return the k most frequent elements. Your answer should be sorted by frequency f…
[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]722. Remove Comments 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/remove-comments/description/ 题目描述: Given a C++ program, remove comments from it. The program source is an array where source[i] is the i-th line of the source…
Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. Note: The length of num is less than 10002 and will be ≥ k. The given num does not contain any leading zero. Ex…
Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. Note: The length of num is less than 10002 and will be ≥ k. The given num does not contain any leading zero. Ex…