上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 33 下一页
摘要: import java.util.Stack; public class CQueue { Stack<Integer> stack1 = new Stack<>(); Stack<Integer> stack2 = new Stack<>(); public CQueue() { } public 阅读全文
posted @ 2020-08-07 11:02 欣姐姐 阅读(96) 评论(0) 推荐(0)
摘要: 递归: public TreeNode buildTree(int[] preorder, int[] inorder) { int len = preorder.length; if(len == 0) return null; TreeNode head = new TreeNode(preor 阅读全文
posted @ 2020-08-07 10:09 欣姐姐 阅读(88) 评论(0) 推荐(0)
摘要: 虽然很快做出来,但是性能并不好; 用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)
摘要: 用时2分52秒: 用差值进行计算: public int maxProfit(int[] prices) { int n = prices.length; if(n <= 1) return 0; int interest = 0; for(int i = 1;i<n;i++){ int pri = 阅读全文
posted @ 2020-08-05 10:40 欣姐姐 阅读(109) 评论(0) 推荐(0)
摘要: 顺利完成! 思路: 先找0的位置; 判断是否可以跳过位置0。 public boolean canJump(int[] nums) { int n = nums.length; if(n <=1){ return true; } if(nums[0] == 0){ return false; } f 阅读全文
posted @ 2020-08-04 12:05 欣姐姐 阅读(140) 评论(0) 推荐(0)
摘要: 做出来了,但是时间用的比较长。 用了递归。 public void solve(char[][] board) { int m = board.length; if(m == 0){ return; } int n = board[0].length; if(n == 0){ return; } b 阅读全文
posted @ 2020-08-03 14:56 欣姐姐 阅读(114) 评论(0) 推荐(0)
摘要: 自己做的时候老是想着走捷径,其实代码不都是从最复杂最直白的思路开始,然后一步一步进行优化的吗,所以还是不能心急。 这道题我这次没做出来,踏踏实实来。 public List<List<String>> findLadders(String beginWord, String endWord, Lis 阅读全文
posted @ 2020-08-03 12:57 欣姐姐 阅读(142) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 33 下一页