全站内容
Calf
这里收录 Calf 在 GoCalf 上的文章、笔记与其他内容。
200. Number of Islands
#Problem Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You …
2017. Grid Game
#Problem You are given a 0-indexed 2D array grid of size 2 x n, where grid[r][c] represents the number of points at position (r, c) on the matrix. Two robots are playing a game on this matrix. Both robots initially start at (0, 0) and want …
2054. Two Best Non-Overlapping Events
#Problem You are given a 0-indexed 2D integer array of events where events[i] = [startTimeᵢ, endTimeᵢ, valueᵢ]. The iᵗʰ event starts at startTimeᵢ and ends at endTimeᵢ, and if you attend this event, you will receive a value of valueᵢ. You …
2056. Number of Valid Move Combinations On Chessboard
#Problem There is an 8 x 8 chessboard containing n pieces (rooks, queens, or bishops). You are given a string array pieces of length n, where pieces[i] describes the type (rook, queen, or bishop) of the iᵗʰ piece. In addition, you are given …
206. Reverse Linked List
#Problem Given the head of a singly linked list, reverse the list, and return the reversed list. https://leetcode.com/problems/reverse-linked-list/ Example 1: case1Input: head = [1,2,3,4,5] Output: [5,4,3,2,1] Example 2: case2Input: head = …
207. Course Schedule
#Problem There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [aᵢ, bᵢ] indicates that you must take course bᵢ first if you want to take …
208. Implement Trie (Prefix Tree)
#Problem A trie (pronounced as “try”) or prefix tree is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker. …
2080. Range Frequency Queries
#Problem Design a data structure to find the frequency of a given value in a given subarray. The frequency of a value in a subarray is the number of occurrences of that value in the subarray. Implement the RangeFreqQuery class: …
2097. Valid Arrangement of Pairs
#Problem You are given a 0-indexed 2D integer array pairs where pairs[i] = [startᵢ, endᵢ]. An arrangement of pairs is valid if for every index i where 1 <= i < pairs.length, we have endᵢ₋₁ == startᵢ. Return any valid arrangement of pairs. …
21. Merge Two Sorted Lists
#Problem You are given the heads of two sorted linked lists list1 and list2. Merge the two lists into one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head of the merged linked list. …