摘要: /** * 一个数组,一半奇数,一半是偶数,要将数组按照偶奇偶奇的顺序排序 * 思路,找出下标是偶数但值是奇数的,和下标是奇数但值是偶数的,两个互换,直到结束 */ public class SortArrayByParityll { public static void main(String[] 阅读全文
posted @ 2019-11-06 15:48 踏月而来 阅读(1095) 评论(0) 推荐(0) 编辑
摘要: /** * 使用两个指针i和j,初始化均为0。然后j往后遍历,若遇到了奇数,则将 A[j] 和 A[i] 交换位置,同时i自增1,这样操作下来,同样可以将所有的偶数都放在奇数前面 * */ public class SortArrayByParity { public static void mai 阅读全文
posted @ 2019-11-06 14:47 踏月而来 阅读(1264) 评论(0) 推荐(0) 编辑
摘要: 动态规划 /** * 硬币找零, 假如你的硬币面值有1,2,5等,每种面值的都有无数个,求找零100最少要多少个硬币 * */ public class CoinChange { public static void main(String[] args) { int [] coins = new 阅读全文
posted @ 2019-11-06 12:10 踏月而来 阅读(155) 评论(0) 推荐(0) 编辑