全站内容
Calf
这里收录 Calf 在 GoCalf 上的文章、笔记与其他内容。
54. Spiral Matrix
#Problem Given an m x n matrix, return all elements of the matrix in spiral order. https://leetcode.com/problems/spiral-matrix/ Example 1: case1Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] Output: [1,2,3,6,9,8,7,4,5] Example 2: case2Input: …
540. Single Element in a Sorted Array
#Problem You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Return the single element that appears only once. Your solution must run in …
541. Reverse String II
#Problem Given a string s and an integer k, reverse the first k characters for every 2k characters counting from the start of the string. If there are fewer than k characters left, reverse all of them. If there are less than 2k but greater …
542. 01 Matrix
#Problem Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell. The distance between two cells sharing a common edge is 1. https://leetcode.com/problems/01-matrix/ Example 1: case1Input: mat = …
55. Jump Game
#Problem You are given an integer array nums. You are initially positioned at the array’s first index, and each element in the array represents your maximum jump length at that position. Return true if you can reach the last index, or false …
56. Merge Intervals
#Problem Given an array of intervals where intervals[i] = [startᵢ, endᵢ], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input. …
57. Insert Interval
#Problem You are given an array of non-overlapping intervals intervals where intervals[i] = [startᵢ, endᵢ] represent the start and the end of the iᵗʰ interval and intervals is sorted in ascending order by startᵢ. You are also given an …
572. Subtree of Another Tree
#Problem Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and false otherwise. A subtree of a binary tree tree is a tree that consists of a …
581. Shortest Unsorted Continuous Subarray
#Problem Given an integer array nums, you need to find one continuous subarray such that if you only sort this subarray in non-decreasing order, then the whole array will be sorted in non-decreasing order. Return the shortest such subarray …
59. Spiral Matrix II
#Problem Given a positive integer n, generate an n x n matrix filled with elements from 1 to n² in spiral order. https://leetcode.cn/problems/spiral-matrix-ii/ Example 1: case1Input: n = 3 Output: [[1,2,3],[8,9,4],[7,6,5]] Example 2: Input: …