Weikoi

导航

2020年3月4日 #

Leetcode-013-罗马数字转整数

摘要: 双指针问题,当前的数小于后一位,就减去它的值,否则就加上它的值。 class Solution { public int romanToInt(String s) { Map<Character, Integer> demo = new HashMap<>(); demo.put('I', 1); 阅读全文

posted @ 2020-03-04 23:54 Weikoi 阅读(107) 评论(0) 推荐(0)

Leetcode-012-整数转罗马数字

摘要: 贪心算法,表达的种类是有穷尽的,从大到小进行贪心就好。 class Solution { public String intToRoman(int num) { int[] nums= new int[]{1000,900,500,400,100,90,50,40,10,9,5,4,1}; Stri 阅读全文

posted @ 2020-03-04 13:09 Weikoi 阅读(92) 评论(0) 推荐(0)