摘要:
/** * 思想简单,用一个指针指向第二个重复的字符即可,然后判断每一段的大小,通过map保存没有重复字符的索引 */ public static int lengthOfLongestSubstring(String s) { int pre=0,maxlen=0; Map<Character, 阅读全文
摘要:
public static int[] twoSum(int[] nums, int target) { Map<Integer,Integer> map = new HashMap(); int[] a = new int[2]; for (int i = 0; i < nums.length; 阅读全文
摘要:
public static int[] sortedSquares(int[] nums) { //定义一个双指针 int left=0,right=nums.length-1; int[] res = new int[right+1]; //因为新数组需要排序 for (int i = nums. 阅读全文