Pow(x, n)
LeetCode https://leetcode.cn/problems/powx-n/ class Solution { public double myPow(double x, int n) { if (x == 0 && n <= 0) { return -1; } else if (n &...
LeetCode https://leetcode.cn/problems/powx-n/ class Solution { public double myPow(double x, int n) { if (x == 0 && n <= 0) { return -1; } else if (n &...
LeetCode https://leetcode.cn/problems/word-search/ class Solution { public boolean exist(char[][] board, String word) { int h = board.length, w = board[0].length; boolean[][] v...
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:...