摘要:
public int lengthOfLongestSubstring(String s) { // 开一个hashmap来维护情况,进行一个N*N的搜索 Map<Character, Boolean> map; int len = s.length(); if(len == 0) return 0 阅读全文
摘要:
public List<List<Integer>> threeSum(int[] nums) { List<List<Integer>> ans = new ArrayList<>(); List<Integer> combine = new ArrayList<>(); dfs(nums, an 阅读全文
摘要:
public void rotate(int[][] matrix) { int n = matrix.length, m= n-1; for(int i = 0; i < n/2; i++) { for(int j = 0; j < n/2; j++) { int tmp = matrix[i][ 阅读全文
摘要:
public int maxSubArray(int[] nums) { int len = nums.length,ans = nums[0]; int[] dp = new int[len]; dp[0] = nums[0]; for(int i = 1; i < len; i++) { dp[ 阅读全文
摘要:
public int maxProfit(int[] prices) { if(prices.length < 2) return 0; int ans = 0, beforeMin = prices[0]; for(int i =1; i < prices.length; i++) { int p 阅读全文
摘要:
public int findDuplicate(int[] nums) { Arrays.sort(nums); System.out.println(Arrays.toString(nums)); int l = 0, r = nums.length - 1; while (l < r) { i 阅读全文
摘要:
public int findInMountainArray(int target, MountainArray mountainArr) { int len = mountainArr.length(); int l = 0, r = len; while(l < r) { int mid = l 阅读全文
摘要:
``java public List<List> combinationSum(int[] candidates, int target) { List<List> ans = new ArrayList<>(); List combine = new ArrayList<>(); dfs(cand 阅读全文
摘要:
`private int m,n; private int[] dx = {-1, 0, 1, 0}; private int[] dy = {0, -1, 0, 1}; public int minPathSum(int[][] grid) { m = grid.length; n = grid[ 阅读全文
摘要:
public List<List> combinationSum(int[] candidates, int target) { List<List> ans = new ArrayList<>(); List combine = new ArrayList<>(); dfs(candidates, 阅读全文