摘要: 题目: 解:双指针;map public int[] intersect(int[] nums1, int[] nums2) { // 先对两个数组进行排序 Arrays.sort(nums1); Arrays.sort(nums2); int i = 0; int j = 0; List<Inte 阅读全文
posted @ 2022-04-22 09:08 仙人掌掌掌掌 阅读(51) 评论(0) 推荐(0)
摘要: 题目: 解: public int[] plusOne(int[] digits) { int length = digits.length; for (int i = length - 1; i >= 0; i--) { if (digits[i] != 9) { //如果数组当前元素不等于9,直 阅读全文
posted @ 2022-04-22 09:08 仙人掌掌掌掌 阅读(483) 评论(0) 推荐(0)
摘要: 题目: 解:位运算解决;使用集合Set解决 public int singleNumber(int nums[]) { int result = 0; for (int i = 0; i < nums.length; i++) result ^= nums[i]; return result;}​ 阅读全文
posted @ 2022-04-22 09:06 仙人掌掌掌掌 阅读(30) 评论(0) 推荐(0)
摘要: 题目: 解:Arrays.sort(nums);set集合 public boolean containsDuplicate(int[] nums) { Set<Integer> set = new HashSet<>(); for (int num : nums) { //因为集合set中不能有重 阅读全文
posted @ 2022-04-22 09:04 仙人掌掌掌掌 阅读(25) 评论(0) 推荐(0)
摘要: 题目: 解:(i + k) % length class Solution { public void rotate(int nums[], int k) { int length = nums.length; int temp[] = new int[length]; //把原数组值放到一个临时数 阅读全文
posted @ 2022-04-22 09:00 仙人掌掌掌掌 阅读(31) 评论(0) 推荐(0)
摘要: 题目: 解: public int maxProfit(int[] prices) { if (prices == null || prices.length < 2) return 0; int total = 0, index = 0, length = prices.length; while 阅读全文
posted @ 2022-04-22 08:59 仙人掌掌掌掌 阅读(29) 评论(0) 推荐(0)
摘要: 题目: 解: 快慢双指针解决 使用两个指针,右指针始终往右移动, 如果右指针指向的值等于左指针指向的值,左指针不动。 如果右指针指向的值不等于左指针指向的值,那么左指针往右移一步,然后再把右指针指向的值赋给左指针。 public int removeDuplicates(int[] A) { //边 阅读全文
posted @ 2022-04-22 08:55 仙人掌掌掌掌 阅读(35) 评论(1) 推荐(0)
摘要: File类 IO流概述 节点流(或文件流) 缓冲流的使用 转换流的使用 其它的流的使用 对象流的使用 RandomAccessFile的使用 Path、Paths、Files的使用 File类 File类的理解 1. File类的一个对象,代表一个文件或一个文件目录(俗称:文件夹) 2. File类 阅读全文
posted @ 2021-06-24 17:39 仙人掌掌掌掌 阅读(104) 评论(0) 推荐(0)
摘要: 数组存储的弊端 Collection接口 Iterator接口 foreach循环 List接口 Set接口 Map接口 Collections工具类的使用 数组存储的弊端: > 一旦初始化以后,其长度就不可修改。 > 数组中提供的方法非常限,对于添加、删除、插入数据等操作,非常不便,同时效率不高。 阅读全文
posted @ 2021-06-23 10:06 仙人掌掌掌掌 阅读(89) 评论(0) 推荐(0)
摘要: 目录 枚举 泛型 枚举 枚举类创建: enum Season1 { //1.提供当前枚举类的对象,多个对象之间用","隔开,末尾对象";"结束 SPRING("春天","春暖花开"), SUMMER("夏天","夏日炎炎"), AUTUMN("秋天","秋高气爽"), WINTER("冬天","冰天 阅读全文
posted @ 2021-06-09 23:35 仙人掌掌掌掌 阅读(532) 评论(0) 推荐(0)