摘要: public int maxValue(int[][] grid) { //动态规划 int m = grid.length; int n = grid[0].length; for(int i = 1;i<n;i++){ grid[0][i] = grid[0][i] + grid[0][i-1] 阅读全文
posted @ 2020-08-24 22:22 欣姐姐 阅读(172) 评论(0) 推荐(0) 编辑
摘要: public int lengthOfLongestSubstring(String s) { //用哈希表存储 int len = s.length(); if(len<=1) return len; char[] c = s.toCharArray(); HashMap<Character,In 阅读全文
posted @ 2020-08-24 22:07 欣姐姐 阅读(147) 评论(0) 推荐(0) 编辑
摘要: public int nthUglyNumber(int n) { int a = 0,b = 0,c = 0; int[] dp = new int[n]; dp[0] = 1; for(int i = 1;i<n;i++){ int n2 = dp[a]*2,n3 = dp[b]*3,n5 = 阅读全文
posted @ 2020-08-24 20:29 欣姐姐 阅读(104) 评论(0) 推荐(0) 编辑
摘要: public int singleNumber(int[] nums) { int ones = 0, twos = 0; for(int num : nums){ ones = ones ^ num & ~twos; twos = twos ^ num & ~ones; } return ones 阅读全文
posted @ 2020-08-24 17:37 欣姐姐 阅读(153) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int[] singleNumbers(int[] nums) { Arrays.sort(nums); int i = 1,j = 0; int c = 0; ArrayList<Integer> list = new ArrayList<>(); 阅读全文
posted @ 2020-08-24 17:06 欣姐姐 阅读(347) 评论(0) 推荐(0) 编辑
摘要: class MaxQueue { Queue<Integer> queue; LinkedList<Integer> max; public MaxQueue() { queue = new LinkedList<>(); max = new LinkedList<>(); } public int 阅读全文
posted @ 2020-08-24 15:46 欣姐姐 阅读(91) 评论(0) 推荐(0) 编辑
摘要: public int maxProfit(int[] prices) { int n = prices.length; if(n == 0) return 0; int[] x = new int[n]; x[0] = prices[0]; int max = -1; for(int i = 1;i 阅读全文
posted @ 2020-08-24 15:02 欣姐姐 阅读(113) 评论(0) 推荐(0) 编辑
摘要: public int sumNums(int n) { boolean flag = n > 0 && (n+=sumNums(n-1))>0; return n; } public int sumNums(int n) { return IntStream.range(1,n+1).sum(); 阅读全文
posted @ 2020-08-24 10:09 欣姐姐 阅读(139) 评论(0) 推荐(0) 编辑