算法训练 特殊的数字四十 时间限制:1.0s 内存限制:256.0MB 特殊的数字四十 问题描述 1234是一个非常特殊的四位数,因为它的各位数之和为10,编程求所有这样的四位十进制数. 输出格式 按从小到大的顺序输出满足条件的四位十进制数.每个数字占用一行. 示例代码: public class Main { public static void main(String[] args) { for(int i = 1000; i <= 9999; i++){ int a = i /…
LeetCode第27题 Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. The…
给定一个以字符串表示的非负整数 num,移除这个数中的 k 位数字,使得剩下的数字最小. leetcode 解题思路:如果这个数的各个位是递增的,那么直接从最后面开始移除一定就是最最小的:如果这个数的位值不是底层的,那么,尽量移除高位的逆序数字.如果最后变成递增了之后,k还有的剩,就再从后面移除大的数字. 记得需要移除高位的没有用的零. class Solution { public String removeKdigits(String num, int k) { StringBuilder…