摘要:
1704. 判断字符串的两半是否相似 class Solution { public boolean halvesAreAlike(String s) { Set<Character> set = new HashSet<>(); set.add('a'); set.add('e'); set.ad 阅读全文
摘要:
864. 获取所有钥匙的最短路径 题解: bfs 总共不超过6把钥匙,通过位运算保存钥匙 class Solution { public int shortestPathAllKeys(String[] grid) { int[][][] dist = new int[31][31][64]; in 阅读全文
摘要:
1684. 统计一致字符串的数目 class Solution { public int countConsistentStrings(String allowed, String[] words) { int[] flag = new int[30]; char[] all = allowed.t 阅读全文
摘要:
33. 搜索旋转排序数组 题解: 二分找出翻转的位置 然后判断在target在前后哪个区间,二分找到target的位置 class Solution { public int search(int[] nums, int target) { int n = nums.length; if (n == 阅读全文
摘要:
31. 下一个排列 题解: 从后往前找第一个降序的点的下标 a 从该点x出发 往后找 第一个比该点大的数,下标为 b 两个数交换,然后将 a 后面的数 翻转过来 public void nextPermutation(int[] nums) { int k = nums.length - 1; wh 阅读全文