全站内容
Calf
这里收录 Calf 在 GoCalf 上的文章、笔记与其他内容。
2109. Adding Spaces to a String
#Problem You are given a 0-indexed string s and a 0-indexed integer array spaces that describes the indices in the original string where spaces will be added. Each space should be inserted before the character at the given index. For …
211. Design Add and Search Words Data Structure
#Problem Design a data structure that supports adding new words and finding if a string matches any previously added string. Implement the WordDictionary class: WordDictionary() Initializes the object. void addWord(word) Adds word to the …
2116. Check if a Parentheses String Can Be Valid
#Problem A parentheses string is a non-empty string consisting only of '(' and ')'. It is valid if any of the following conditions is true: It is (). It can be written as AB (A concatenated with B), where A and B are valid parentheses …
212. Word Search II
#Problem Given an m x n board of characters and a list of strings words, return all words on the board. Each word must be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically …
2127. Maximum Employees to Be Invited to a Meeting
#Problem A company is organizing a meeting and has a list of n employees, waiting to be invited. They have arranged for a large circular table, capable of seating any number of employees. The employees are numbered from 0 to n - 1. Each …
213. House Robber II
#Problem You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first house is the neighbor of the last one. …
217. Contains Duplicate
#Problem Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. https://leetcode.com/problems/contains-duplicate/ Example 1: Input: nums = [1,2,3,1] Output: …
2182. Construct String With Repeat Limit
#Problem You are given a string s and an integer repeatLimit. Construct a new string repeatLimitedString using the characters of s such that no letter appears more than repeatLimit times in a row. You do not have to use all characters from …
2185. Counting Words With a Given Prefix
#Problem You are given an array of strings words and a string pref. Return the number of strings in words that contain pref as a prefix. A prefix of a string s is any leading contiguous substring of s. …
219. Contains Duplicate II
#Problem Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k. https://leetcode.cn/problems/contains-duplicate-ii/ Example 1: …