随笔分类 -  左神面试指南

摘要:CD79 一种消息接收并打印的结构设计 public class CD79_1 { public static class Node { public int num; public Node next; public Node(int num) { this.num = num; } } publ 阅读全文
posted @ 2023-11-26 21:05 Vivid-BinGo 阅读(20) 评论(0) 推荐(0) 编辑
摘要:CD66 并查集的实现 public class CD66_1 { public static class Solution { int[] f; public Solution(int n) { f = new int[n]; Arrays.fill(f, -1); } private int f 阅读全文
posted @ 2023-11-26 12:37 Vivid-BinGo 阅读(17) 评论(0) 推荐(0) 编辑
摘要:CDxxx 从 5 随机到 7 随机及其扩展 /* rand1To5实现等概率随机产生1~7的随机函数rand1To7 */ public int rand1To5() { return (int) (Math.random() * 5) + 1; } public int rand1To7() { 阅读全文
posted @ 2023-11-24 18:15 Vivid-BinGo 阅读(6) 评论(0) 推荐(0) 编辑
摘要:CD26 子数组的最大累加和问题 public class CD26_1 { public static int solution(int[] arr) { int ans = -1, sum = 0; for (int num : arr) { if (sum + num > 0) { sum + 阅读全文
posted @ 2023-11-23 22:03 Vivid-BinGo 阅读(7) 评论(0) 推荐(0) 编辑
摘要:CD149 转圈打印矩阵 public class CD149_1 { public static void solution(int[][] arr) { int up = 0, down = arr.length - 1, left = 0, right = arr[0].length - 1; 阅读全文
posted @ 2023-11-22 18:40 Vivid-BinGo 阅读(8) 评论(0) 推荐(0) 编辑
摘要:CD142 不用额外变量交换两个整数的值 /* 模拟 */ public class CD142_1 { public static void solution(int a, int b) { a = a ^ b; b = a ^ b; a = a ^ b; System.out.println(a 阅读全文
posted @ 2023-11-21 16:27 Vivid-BinGo 阅读(5) 评论(0) 推荐(0) 编辑
摘要:CD126 括号字符串的有效性 /* 模拟 */ public class CD126_1 { public static String solution(String s) { int l = 0, r = 0; for (char ch : s.toCharArray()) { if (ch = 阅读全文
posted @ 2023-11-20 13:33 Vivid-BinGo 阅读(11) 评论(0) 推荐(0) 编辑
摘要:CD95 判断两个字符串是否互为变形词 /* 模拟 */ public class CD95_1 { public static boolean solution(String s1, String s2) { if (s1.length() != s2.length()) return false 阅读全文
posted @ 2023-11-16 14:03 Vivid-BinGo 阅读(13) 评论(0) 推荐(0) 编辑
摘要:CD42 子数组异或和为 0 的最多划分⭐ /*⭐DP⭐*/ public class CD42_1 { public static int solution(int[] arr) { HashMap<Integer, Integer> map = new HashMap<>(); int[] dp 阅读全文
posted @ 2023-11-14 21:09 Vivid-BinGo 阅读(8) 评论(0) 推荐(0) 编辑
摘要:CD183 斐波那契数列问题的递归和动态规划1 /* * 矩阵快速幂 * [f(n), f(n-1)] = [1, 1] x [[1, 1], [1, 0]]^(n-2) */ public class CD183_1 { public static long solution(long n) { 阅读全文
posted @ 2023-11-13 22:10 Vivid-BinGo 阅读(9) 评论(0) 推荐(0) 编辑
摘要:CD172 判断二叉树是否为平衡二叉树 /* 递归 */ public class CD172_1 { public static class TreeNode { public int val; public TreeNode left; public TreeNode right; public 阅读全文
posted @ 2023-11-12 21:42 Vivid-BinGo 阅读(9) 评论(0) 推荐(0) 编辑
摘要:CD161 用递归和非递归方式实现二叉树先序、中序和后序遍历❗ public class CD161_1 { public static class TreeNode { public int val; public TreeNode left; public TreeNode right; pub 阅读全文
posted @ 2023-11-10 20:13 Vivid-BinGo 阅读(7) 评论(0) 推荐(0) 编辑
摘要:CDxxx 两个单链表相交的一系列问题⭐ 剑指offer 链表篇 JZ52 两个链表的第一个公共结点 剑指offer 链表篇 JZ23 链表中环的入口结点 public Node getIntersectNode(Node head1, Node head2) { if (head1 == null 阅读全文
posted @ 2023-11-09 13:50 Vivid-BinGo 阅读(4) 评论(0) 推荐(0) 编辑
摘要:CD48 打印两个有序链表的公共部分 /* 归并 */ public class CD48_1 { public static class ListNode { public int val; public ListNode next = null; public ListNode(int val) 阅读全文
posted @ 2023-11-08 12:32 Vivid-BinGo 阅读(12) 评论(0) 推荐(0) 编辑
摘要:CD5 设计一个有 getMin 功能的栈 /* * 维护一个最小栈minStack * dataStack每压入一个数, minStack也压入一个当前状态的最小值 */ public class CD5_1 { public static class Solution { public Stac 阅读全文
posted @ 2023-11-07 16:07 Vivid-BinGo 阅读(33) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示