自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(14)
  • 收藏
  • 关注

原创 两个线程循环打印

public static void main(String[] args){ Number number = new Number(); Thread t1 = new Thread(number); Thread t2 = new Thread(number); t1.setName("线程1"); t2.setName("线程2"); t1.st...

2021-07-27 21:07:09 182

原创 字符串滑窗

leetcode hot 100/76 public String minWindow(String s, String t) { if(s==null||t==null||s.length()==0||t.length()==0) return ""; int l =0,r =0; int[] need = new int[128];//ascii一共有128个字符 int count = t.length(); //记录总共要找的字

2021-06-18 16:46:14 73

原创 不同类型的返回值

1.当返回值为二维数组时返回值是一个二维数组时,先新建一个List<int[]> res = new ArrayList<>();最终return res.toArray(new int[res.size()][]); 然后在中间过程中可以新建一个数组,将数组arr 直接加入到 res 中 res.add(arr);剑指offer57-2 滑动窗口 public int[][] findContinuousSequence(int target) {

2021-06-17 15:38:29 224

原创 手动实现一个hashmap对同字母不同排列的放到统一的数组中

//手动实现一个hashmappublic List<List<String>> groupAnagrams(String[] strs) { List<List<String>> res = new ArrayList<>(); Deque<String> deque = new LinkedList<>(); HashMap<String,List<Stri.

2021-06-14 10:14:50 79

原创 List<List<Integer>>转换

List<List<Integer>> res = new ArrayList<>(); int len; public List<List<Integer>> combinationSum(int[] candidates, int target) { len = candidates.length; if(len==0) return res; //Arrays.sort...

2021-06-11 10:39:47 282

原创 2021-06-11

public char firstUniqChar(String s) { int[] arr = new int[26]; char[] chars = s.toCharArray(); for (char ch : chars){ arr[ch -'a'] ++; } for (char c:chars){ if (arr[c-'a'] == 1){ .

2021-06-11 10:08:24 68 1

原创 2021-06-05

List<List<Integer>> res = new ArrayList<>(); int len; public List<List<Integer>> combinationSum(int[] candidates, int target) { len = candidates.length; if(len==0) return res; Arrays.sort(can..

2021-06-05 22:00:21 44

原创 最长回文子串 leetcode 5

//暴力做法 超时 public boolean check(String s){ int len = s.length(); for(int i = 0;i<len/2;i++){ if(s.charAt(i)!=s.charAt(len-i-1)){ return false; } } return true; } publ

2021-05-23 18:08:54 66

原创 最长递增子序列 leetcode 300

DP求解 public int lengthOfLIS(int[] nums) { if(nums.length==0) return 0; int[] dp = new int[nums.length]; int res = 0; Arrays.fill(dp,1); for(int i=0;i<nums.length;i++){ for(int j=0;j<i;j++){

2021-05-19 15:54:52 53

原创 三角形最小路径和

三角形最小路径和 (leetcode 120题)DP求解 public int minimumTotal(List<List<Integer>> triangle) { int n = triangle.size()+1; int[][] f = new int[n][n]; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){

2021-05-19 15:51:16 36

原创 dfs解决全排列问题

dfs处理全排列问题最基本版,单纯搜索无剪枝, 剑指offer 38 会超时 List<String> res = new LinkedList<>(); char[] c; //存储原字符串数组 int n; //记录字符串长度 boolean[] judge; //记录已经遍历的变量,防止重复遍历 char[] path; //记录已经走过的路径 public void permutation(String s) {

2021-05-17 15:38:38 163

原创 KMP算法 leetcode 28

public void kmp(){ int n=3; String P = "aba"; char[] p = new char[n + 1]; for (int i = 1; i <= n; i++) p[i] = P.charAt(i - 1); int m = 5; String S = "ababa"; // 总串s char[] s =

2021-05-15 15:29:23 68

原创 二分查找左右边界

#二分查找//查找该数字的左边界的坐标值 public int findl(int[] arr,int target,int l ,int r){ while (l<r){ int mid = (l+r)/2; if(arr[mid]>=target) r = mid; else l = mid+1; } return l; } //查找该数字的右边界的坐标

2021-05-06 15:57:30 296

原创 排序算法3

排序算法快速排序归并排序快速排序public void sortQuick(int[] arr,int l ,int r){if(l>=r) return; int mid = arr[(l+r)/2]; int i = l-1; int j = r+1; while(i<j){ do{i++}; while(arr[i]<mid); do{j--};while(arr[j]>mid); if(i<j){ swap(arr[i],a

2021-05-06 10:31:31 102

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除