自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 请教关于Java nio涉及字符集的问题

import java.io.File;import java.io.IOException;import java.io.FileInputStream;import java.io.FileOutputStream;import java.nio.Buffer;import java.nio.ByteBuffer;import java.nio.channels.FileChannel;import java.nio.charset.Charset;public class Main {

2022-02-19 15:33:35 297 1

原创 flatdemo使用小记录

public class FlatMapTest { public List<List<Person>> f() { List<List<Person>> list = new ArrayList<>(); for (int i = 0; i < 5; i++) { List<Person> listPerson = new ArrayList<>();

2021-11-12 19:25:56 208

原创 leetcode-457环形数组是否存在循环

public class CircularArrayLoop { public boolean circularArrayLoop(int[] nums) { Set<Integer> set = new HashSet<>(); boolean flag; for (int i = 0; i < nums.length; i++) { int j = i; flag = (

2021-11-10 16:16:04 63

原创 压缩字符串leetcode-443

class Solution { public int compress(char[] chars) { int i = -1; int j = 0; while (j < chars.length) { int k = j; while (k < chars.length && chars[k] == chars[j]) { k++;

2021-11-10 15:24:27 4516

原创 寻找重复数leetcode-287

class Solution { public int findDuplicate(int[] nums) { int start = 0; int end = nums.length - 1; while (start < end) { int mid = (start + end) / 2; int count = 0; for (int i = 0; i < n

2021-11-10 14:26:35 3575

原创 leetcode-189轮转数组

class Solution { public void rotate(int[] nums, int k) { int position = 0; int circle = 0; int[] tmpNums = new int[nums.length]; for (int i = 0; i < nums.length; i++) { tmpNums[i] = nums[i]; }

2021-11-10 11:28:32 80

原创 leetcode-165

public class CompareVersion { public int compareVersion(String version1, String version2) { String[] stringArray = version1.split("\\."); String[] stringArray2 = version2.split("\\."); for (int i = 0, j = 0; i < stringArray.

2021-11-10 11:01:18 5133

原创 删除排序链表中的重复元素 II leetcode-82

public ListNode deleteDuplicates(ListNode head) { if (head == null) { return null; } ListNode p = new ListNode(); p.next = head; ListNode result = p; while (p.next != null) {

2021-11-10 00:20:24 203

原创 删除有序数组的重复项II

public class RemoveDuplicates { public int removeDuplicates(int[] nums) { int i = 0; int j = 0; int length = nums.length; while (i < length) { while (j < length && nums[j] == nums[i]) {

2021-11-09 21:08:46 36

原创 旋转链表leetcode-61

/** * 旋转链表leetcode-61 */public class RotateRight { public ListNode rotateRight(ListNode head, int k) { if (head == null) { return null; } ListNode p = head; ListNode q = head; int nodeNum = 1;

2021-11-09 20:40:12 175

原创 下一个排列leetcode-31

public class NextPermutation { public void nextPermutation(int[] nums) { int i; for (i = nums.length - 1; i > 0; i--) { if (nums[i] > nums[i - 1]) { int j = nums.length - 1; while (nums[

2021-11-09 20:23:26 52

原创 四数之和leetcode-18

public class FourSum { public List<List<Integer>> fourSum(int[] nums, int target) { for (int i = 0; i < nums.length - 1; i++) { for (int j = nums.length - 1; j > i; j--) { if (nums[j] < nums[j -

2021-11-09 17:27:55 49

原创 盛水最多的容器leetcode-11

public class MaxArea { public int maxArea(int[] height) { int sum = 0; for (int i = 0, j = height.length - 1; i < j;) { if (sum < Math.min(height[i], height[j]) * (j - i)) { sum = Math.min(height[i], he

2021-11-09 16:36:24 490

原创 猜数字游戏leetcode-299

官方写法更简单class Solution { public String getHint(String secret, String guess) { char[] guessChars = guess.toCharArray(); int cow = 0; int bulls = 0; List<List<Integer>> positionList = new ArrayList<>();

2021-11-08 14:04:15 2232

原创 最接近的三数之和leetcode-16

这道题采用双指针class Solution { public int threeSumClosest(int[] nums, int target) { for (int m = 0; m < nums.length; m++) { for (int n = nums.length - 1; n > m; n--) { if (nums[n] < nums[m]) {

2021-11-08 11:48:29 36

原创 简单Java流使用

public class StreamPractice { Child liMing = new Child("LiMing", "Shanghai"); Child yeWen = new Child("IpMan", "FoShan"); Child liLi = new Child("LiLi", "Shanghai"); Child liChao = new Child("LiChao", "Shanghai"); List<Toy> toys

2021-11-03 19:26:40 71

原创 2021-09-04

你懂Java代理吗?1.面向对象面向对象的语言中,所有任务都是通过对象完成的。在Java中,对象指的就是类。Java类通过方法对外提供服务,也就是我们所说的api。2.Java 方法java方法的构成元素从逻辑上分为两部分——形式和功能。形式可以简单的理解为一个方法长什么样子,再具体一点就是方法名,和参数列表。而功能指的是这个方法的实现方式,也就是方法中的代码。3.继承和组合继承和组合都是为了代码复用,但继承针对的是形式的复用,而组合针对的是功能的复用。4.继承和组合的特点继承的特点:与基类

2021-09-04 11:43:07 106 5

空空如也

空空如也

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

TA关注的人

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