- 博客(14)
- 收藏
- 关注
原创 454. 四数相加 II
public int fourSumCount(int[] nums1, int[] nums2, int[] nums3, int[] nums4) { HashMap<Integer, Integer> map = new HashMap<>(); int res = 0; int temp; for (int i : nums1) { for (int j : nums2) { ...
2022-05-15 18:42:33
119
原创 438. 找到字符串中所有字母异位词
利用滑动窗口+哈希表进行实现 public List<Integer> findAnagrams(String s, String p) { ArrayList<Integer> list = new ArrayList<>(); int s_length = s.length(); int p_length = p.length(); int s_map[] = new int[26];
2022-05-14 21:52:08
113
原创 49题-字母异位词分组
给你一个字符串数组,请你将 字母异位词 组合在一起。可以按任意顺序返回结果列表。字母异位词 是由重新排列源单词的字母得到的一个新单词,所有源单词中的字母通常恰好只用一次。 public List<List<String>> groupAnagrams(String[] strs) { HashMap<String, List<String>> map = new HashMap<>(); for (S
2022-05-14 21:40:09
139
原创 冒泡+选择+插入排序
1.冒泡排序(优化前+优化后)//优化前 static void bubble(int a[]) { int temp; for (int i = 0; i < a.length - 1; i++) { for (int j = 0; j < a.length - 1 - i; j++) { //第一趟排序 if (a[j] >= a[j + 1]) {
2022-03-02 17:57:19
233
原创 希尔排序(2种方式)
public static void shellSort(int[] arr) { int temp = 0; int count = 0; for (int gap = arr.length / 2; gap > 0; gap /= 2) { for (int i = gap; i < arr.length; i++) { for (int j = i - gap; j &...
2022-03-02 17:39:45
136
原创 常见排序算法
1. 冒泡排序,平均时间算法复杂度O(n^2) static void bubble(int a[]) { int temp; boolean flag = false; for (int i = 0; i < a.length - 1; i++) { for (int j = 0; j < a.length - 1 - i; j++) { //第一趟排序 if (a[j] >=
2022-02-27 21:00:53
312
原创 迷宫求解(递归+回溯)
二维数组:map[8][7]构成围墙;数字1代表围墙或者障碍物;数字0代表空白处或者可通行处;从array[1][1]出发,到达array[6][5]即为达到出口;初始迷宫图形如下:实现代码如下:public class MiGong { public static void main(String[] args) { //创建一个二位数组 模拟迷宫 //地图 int[][] map = new int[8][7];
2022-02-27 20:53:12
210
原创 死亡八皇后求解(回溯+递归)
public class Queen8 { //定义一个max 有多少皇后 int max = 8; //定义数组array。保存保存八皇后放置的位置结果 //比如:arr={0,4,7,5,2,6,1,3} int[] array = new int[max]; static int count; static int judgeCount; public static void main(String[] args) { .
2022-02-27 20:40:41
627
原创 git push 出错
错误1 :errno:10054git config --global --unset http.prox错误2:time out:git config --global http.proxygit config --global --unset http.proxy
2021-11-27 21:19:16
328
原创 Java反射--getMethod()和getDeclaredMethod()方法的区别
getMethod()只可以访问共有方法 私有变量不能访问;getDeclaredMethod() 可以访问获取私有(暴力破解)和公有变量的方法。public class ReflectMethod { public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, Invo
2021-11-19 12:03:28
582
原创 网络编程-socket.closed 异常
socket.closed异常,在使用BufferedInputStream/BufferedOutputStream 写入字节/字符内容时,记得flush,否则会出现异常。
2021-11-09 10:40:45
545
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人