上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 31 下一页
摘要: 一、题目描述 二、解法 class Solution { public int[] twoSum(int[] nums, int target) { /** * 方法1:暴力枚举。 * 时间复杂度O(n^2),空间复杂度O(1) */ /*for (int i = 0; i < nums.lengt 阅读全文
posted @ 2020-12-10 21:38 不学无墅_NKer 阅读(76) 评论(0) 推荐(0) 编辑
摘要: 一、题目描述 二、解法 class Solution { public String frequencySort(String s) { if (s == null || s.length() <= 2) return s; Map<Character,Integer> map = new Hash 阅读全文
posted @ 2020-12-10 21:37 不学无墅_NKer 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 一、题目描述 二、解法 class Solution { public boolean isIsomorphic(String s, String t) { if (s.length() != t.length()) return false; /** * 方法1:使用HashMap,与LeetCo 阅读全文
posted @ 2020-12-10 21:36 不学无墅_NKer 阅读(85) 评论(0) 推荐(0) 编辑
摘要: 一、题目描述 二、解法 class Solution { public boolean wordPattern(String pattern, String s) { /** * 使用Map * 失败有两种情况: 1.key存在,经过查找字母对应的单词和这个单词不匹配; * 2.key不存在,但是这 阅读全文
posted @ 2020-12-10 21:34 不学无墅_NKer 阅读(59) 评论(0) 推荐(0) 编辑
摘要: 一、题目描述 二、解法 class Solution { public boolean isHappy(int n) { /** * 方法1:用Set检测循环 */ /*Set<Integer> set = new HashSet<>(); while (n != 1) { if (set.cont 阅读全文
posted @ 2020-12-10 21:32 不学无墅_NKer 阅读(66) 评论(0) 推荐(0) 编辑
摘要: 一、题目描述 二、解法 class Solution { public boolean isAnagram(String s, String t) { if (s.length() != t.length()) return false; int[] dict = new int[26]; /** 阅读全文
posted @ 2020-12-10 21:30 不学无墅_NKer 阅读(73) 评论(0) 推荐(0) 编辑
摘要: 一、题目描述 二、解法 class Solution { public int singleNumber(int[] nums) { /*Map<Integer,Integer> map = new HashMap<>(); for (int num : nums) { map.put(num, m 阅读全文
posted @ 2020-12-10 21:28 不学无墅_NKer 阅读(63) 评论(0) 推荐(0) 编辑
摘要: 一、题目描述 ☆☆☆☆二、解法 思路:滑动窗口。 时间复杂度O(n) 和LeetCode438. 找到字符串中所有字母异位词属于同一类型的题,滑动窗口的套路就是 扩张->满足条件->收缩 class Solution { public String minWindow(String s, Strin 阅读全文
posted @ 2020-12-08 10:51 不学无墅_NKer 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 一、题目描述 ☆☆☆二、解法 思路:滑动窗口法。用字母字典法判断两个词是否为字母异位词。 代码1:截取法。(时间效率9.25% (ㄒoㄒ)~~) class Solution { public List<Integer> findAnagrams(String s, String p) { List 阅读全文
posted @ 2020-12-07 22:14 不学无墅_NKer 阅读(57) 评论(0) 推荐(0) 编辑
摘要: 一、题目描述 二、解法 思路:滑动窗口 class Solution { public int lengthOfLongestSubstring(String s) { if (s == null || s.length() == 0) return 0; /*int l = 0, r = 0; i 阅读全文
posted @ 2020-12-07 18:13 不学无墅_NKer 阅读(58) 评论(0) 推荐(0) 编辑
上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 31 下一页