摘要: KMP暴力搜索 1 class Solution { 2 3 public int strStr(String haystack, String needle) { 4 // 获取 haystack 和 needle 的长度 5 int n = haystack.length(), m = need 阅读全文
posted @ 2024-06-18 22:10 清川1 阅读(0) 评论(0) 推荐(0) 编辑
摘要: 简单 3 public class Main { 4 public static void main(String[] args) { 5 String s = "abcdefg"; 6 int count=3; 7 char[] charArray = s.toCharArray(); 8 int 阅读全文
posted @ 2024-06-18 21:41 清川1 阅读(0) 评论(0) 推荐(0) 编辑
摘要: index工作指针 left、right边界指针 1 class Solution { 2 public String reverseWords(String s) { 3 char[] string=s.toCharArray(); 4 int left=0; 5 int right=s.leng 阅读全文
posted @ 2024-06-18 21:30 清川1 阅读(0) 评论(0) 推荐(0) 编辑
摘要: Character.isLetter(s.charAt(i)) 判断是否字母 1 public String reverseStr(String s) { 2 StringBuffer sb = new StringBuffer(); 3 for(int i = 0; i < s.length(); 阅读全文
posted @ 2024-06-16 22:02 清川1 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 1.循环的每次i的起始位置 i=i+2*k 2.交换起始位置 start=i,end=Math.min(ch.length - 1,start + k - 1);判断尾数够不够k个来取决end指针的位置 1 class Solution { 2 public String reverseStr(St 阅读全文
posted @ 2024-06-16 21:38 清川1 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 1.同数字数组 2.主要注意边界为 s.length-i-1 1 class Solution { 2 public void reverseString(char[] s) { 3 for(int i=0;i<s.length/2;i++){ 4 char tep; 5 tep=s[i]; 6 s 阅读全文
posted @ 2024-06-16 20:52 清川1 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 1.与三数之和类似 2.定前两个数,后面使用双指针移动 3.注意109需要用long接,int就超出界限了 4.while (left < right && nums[left] == nums[++left]); 一个循环去除重复 1 class Solution { 2 public List< 阅读全文
posted @ 2024-06-16 20:38 清川1 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 学习瑞吉外卖 阅读全文
posted @ 2024-06-13 22:09 清川1 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 难点在于不能重复 1.将数组进行排序 2.找到合适组合后将三个指针都要进行向后去重操作 1 class Solution { 2 public List<List<Integer>> threeSum(int[] nums) { 3 Arrays.sort(nums); 4 List<List<In 阅读全文
posted @ 2024-06-13 22:09 清川1 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 没看懂 1 class Solution { 2 public List<Integer> findAnagrams(String s, String p) { 3 List<Integer>res=new ArrayList<>(); 4 int[]cnt=new int[26]; 5 int n 阅读全文
posted @ 2024-06-13 21:41 清川1 阅读(1) 评论(0) 推荐(0) 编辑