Sort an Array
LeetCode https://leetcode.cn/problems/sort-an-array/ Quicksort class Solution { public int[] sortArray(int[] nums) { if (nums == null || nums.length <= 1) { return nu...
LeetCode https://leetcode.cn/problems/sort-an-array/ Quicksort class Solution { public int[] sortArray(int[] nums) { if (nums == null || nums.length <= 1) { return nu...
LeetCode https://leetcode.cn/problems/reverse-linked-list/ Method 1: recursion /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ...
LeetCode https://leetcode.cn/problems/fibonacci-number/ Recursive class Solution { public int fib(int n) { // base case if (n == 0 || n == 1) { return n; ...
LeetCode https://leetcode.cn/problems/implement-queue-using-stacks/ class MyQueue { private Deque<Integer> stackOne; private Deque<Integer> stackTwo; public MyQueue() { ...
LeetCode https://leetcode.cn/problems/edit-distance/ ❌ 超出时间限制 class Solution { public int minDistance(String word1, String word2) { // Base case if (word1.isEmpty()) ...
LeetCode https://leetcode.cn/problems/single-number/ class Solution { public int singleNumber(int[] nums) { int single = 0; for (int num : nums) { single ^= num; ...
Leetcode https://leetcode.cn/problems/majority-element/ class Solution { public int majorityElement(int[] nums) { int candidate = nums[0]; int counter = 0; for (int n...
> git status -z -uall error: object file .git/objects/95/7b7fc04d50c424957691e6c2c7c95f2a4e7a55 is empty error: object file .git/objects/95/7b7fc04d50c424957691e6c2c7c95f2a4e7a55 is empty fatal:...
script:记录终端会话 script 命令允许你在 Linux 终端中记录所有输入和输出的交互过程。启动它就像开启了一场终端对话的录音,每一步操作都将被记录。 使用示例: script -tsession.timing session.log 这条命令会启动会话录制,并将所有终端的输入输出保存到 session.log 文件中。你可以像平常一样在终端中操作,所有操作都会被记录下...
安装软件包 要安装一个软件包,使用以下命令: sudo apt install <pkg_name> 例如,要安装Firefox浏览器,可以运行: sudo apt install firefox 更新软件包列表 安装或更新软件包之前,最好先更新本地软件包列表。 运行以下命令: sudo apt update 更新已安装的软件包 要更新已安装的软件包到最新...