问题描述 假设你为一家自动售货机厂家编程序,自动售货机要每次找给顾客最少数量硬币;假设某次顾客投进$1纸币,买了?37的东西,要找?63,那么最少数量就是:2个quarter(?25)、1个dime(?10)和3个penny(?1),一共6个. 分别使用贪心算法,递归,以及递归的优化版本:递归 + ...
分类:
编程语言 时间:
2020-03-23 18:40:44
阅读次数:
303
[toc] 包装类 |name|class|pakage| |: :|: :|: :| |byte|Byte|java.lang| |short|Short|java.lang| |int|Integer|java.lang| |long|Long|java.lang| |float|Float|j ...
分类:
其他好文 时间:
2020-03-23 17:11:14
阅读次数:
73
接口定义 Callable接口 'java public interface Callable { V call() throws Exception; } ' Runnable接口 'java public interface Runnable { public abstract ...
分类:
编程语言 时间:
2020-03-23 15:10:11
阅读次数:
78
CompletableFuture<Integer> ad = null; if (true) { ad = CompletableFuture.supplyAsync(() -> { try { TimeUnit.SECONDS.sleep(1); } catch (InterruptedExce ...
分类:
其他好文 时间:
2020-03-23 12:38:12
阅读次数:
288
1、 思路是将数字转换为字符串进行倒置处理然后再转换为数字,注意转置后数值是否超出范围即可 beat 85%, 贴上代码: class Solution(object): def reverse(self, x): """ :type x: int :rtype: int """ _x = str( ...
分类:
其他好文 时间:
2020-03-23 11:16:59
阅读次数:
78
一 函数原型tf.reverse( tensor, axis, name=None) 参数: tensor:需要进行反转的张量,类型必须为其中的一个uint8, int8, uint16, int16, int32, int64, bool, bfloat16, half, float32, flo ...
分类:
其他好文 时间:
2020-03-22 19:50:54
阅读次数:
83
Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target. ...
分类:
其他好文 时间:
2020-03-22 19:30:38
阅读次数:
66
今天有小伙伴问题了一个题:将一个数逆序列放入列表中,例如1234=>[4,3,2,1]。要求用递归实现。粗看这个题的话,很容易实现的:int转成str,然后倒序,再把列表里面的str转成int。再来看递归:一般递归里面都是要有个结束条件,这个题的结束条件也很好确定,它是这个列表,列表有长度,每次pop一个元素,直到列表的长度等于0的时候,那就可以结束了。先来看个普通的递归方法:defreve
分类:
编程语言 时间:
2020-03-22 17:50:29
阅读次数:
85
代码: public static void main(String[] args) { Integer[] mm = new Integer[] {14561,1264}; for (Integer item : mm) { item=45;//foreach 循环的变量是被transient 修 ...
分类:
其他好文 时间:
2020-03-22 17:27:25
阅读次数:
85
"Three Integers" 枚举$a,b$ 处理 $c$ 最小上界 $cc = cb (c / cb) + 1 cb;$ 最大上界$cc = cb (c / cb) + 0 cb;$ ...
分类:
其他好文 时间:
2020-03-22 12:21:22
阅读次数:
76