为什么说一个中文占三个字节
缘由 在学习java基础时 对于s2,一个中文占用3个字节**,21845个正好占用65535个字节,而且字符串长度是21845,长度和存储也都没超过限制,所以可以编译通过 后来发现这句话是错的, java中char...
hot100之二叉树上
二叉树的中序队列(094) 先看代码 class Solution { public List<Integer> inorderTraversal(TreeNode root) { List<Integer> res = new ArrayList<>(); Stack<TreeNode>...
hot100之链表下
K个一组翻转链表(025) 先看代码 class Solution { public ListNode reverseKGroup(ListNode head, int k) { ListNode dummy = new ListNode(-1, head); ListNode prev = dummy; while(prev.next...
hot100之链表上
相交链表(160) 先看代码 public class Solution { public ListNode getIntersectionNode(ListNode headA, ListNode headB) { ListNode p = headA; ListNode q = headB; while (p != q){ p = p !...
hot100之滑动窗口
无重复字符的最长字串(003) 先看代码 class Solution { public int lengthOfLongestSubstring(String s) { int res = 0; int lef = 0; int rig = 0; int[] memo = new int[128]; while (rig <...
hot100之双指针
移动0(283) 先看代码 class Solution { public void moveZeroes(int[] nums) { int idx0 = 0; for (int idx = 0; idx < nums.length; idx++){ if(nums[idx] != 0){ int temp = nums[idx0]; n...