摘要: 虽然很快做出来,但是性能并不好; 用ArrayList做的: public int[] reversePrint(ListNode head) { ArrayList<Integer> list = new ArrayList<>(); while(head != null){ list.add(0 阅读全文
posted @ 2020-08-06 12:11 欣姐姐 阅读(77) 评论(0) 推荐(0)
摘要: 用了最基本的方法,10分钟才做出来。。 public String replaceSpace(String s) { int n = s.length(); while(true){ int index = s.indexOf(" "); if(index == -1)break; s = s.su 阅读全文
posted @ 2020-08-06 12:03 欣姐姐 阅读(79) 评论(0) 推荐(0)
摘要: 不难,但是没一下子捋顺,做了46分钟42秒才完成。。 public boolean findNumberIn2DArray(int[][] matrix, int target) { int n = matrix.length; //n行 if(n==0) return false; int m = 阅读全文
posted @ 2020-08-06 11:05 欣姐姐 阅读(96) 评论(0) 推荐(0)
摘要: 用时4分02秒,用哈希表做的,显然不够优化: public int findRepeatNumber(int[] nums) { Map<Integer,Integer> map = new HashMap<>(); for (int num : nums) { if (!map.containsK 阅读全文
posted @ 2020-08-06 10:01 欣姐姐 阅读(94) 评论(0) 推荐(0)