GoCalf Calf 的自留地 · 昙花一现

全站内容

Calf

这里收录 Calf 在 GoCalf 上的文章、笔记与其他内容。

  • 3297. Count Substrings That Can Be Rearranged to Contain a String I

    Coding

    #Problem You are given two strings word1 and word2. A string x is called valid if x can be rearranged to have word2 as a prefix. A prefix of a string is a substring that starts from the beginning of the string and extends to any point …

    medium
  • 3298. Count Substrings That Can Be Rearranged to Contain a String II

    Coding

    #Problem 跟 3297. Count Substrings That Can Be Rearranged to Contain a String I 一模一样,只是多了一个注意点: Note that the memory limits in this problem are smaller than usual, so you must implement a solution with a linear runtime complexity. …

    hard
  • 33. Search in Rotated Sorted Array

    Coding

    #Problem There is an integer array nums sorted in ascending order (with distinct values). Prior to being passed to your function, nums is possibly rotated at an unknown pivot index k (1 <= k < nums.length) such that the resulting array is …

    medium
  • 337. House Robber III

    Coding

    #Problem The thief has found himself a new place for his thievery again. There is only one entrance to this area, called root. Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that all …

    medium
  • 338. Counting Bits

    Coding

    #Problem Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1’s in the binary representation of i. https://leetcode.com/problems/counting-bits/ Example 1: Input: n = 2 Output: …

    easy
  • 3389. Minimum Operations to Make Character Frequencies Equal

    Coding

    #Problem You are given a string s. A string t is called good if all characters of t occur the same number of times. You can perform the following operations any number of times: Delete a character from s. Insert a character in s. Change a …

    hard
  • 3395. Subsequences with a Unique Middle Mode I

    Coding

    #Problem 唯一中间众数子序列。 Given an integer array nums, find the number of subsequences of size 5 of nums with a unique middle mode. A subsequence is an array that can be derived from another array by deleting some or no elements without changing …

    hard
  • 3398. Smallest Substring With Identical Characters I

    Coding

    #Problem You are given a binary string s of length n and an integer numOps. You are allowed to perform the following operation on s at most numOps times: Select any index i (where 0 <= i < n) and flip s[i]. If s[i] == '1', change s[i] to …

    hard
  • 3399. Smallest Substring With Identical Characters II

    Coding

    跟 3398. Smallest Substring With Identical Characters I 一模一样,只不过 s 的长度上限从 1000 增加到 10⁵。 https://leetcode.com/problems/smallest-substring-with-identical-characters-ii/ 直接用上次的代码没问题(最大堆或二分法均可)。

    hard
  • 3405. Count the Number of Arrays with K Matching Adjacent Elements

    Coding

    #Problem You are given three integers n, m, k. A good array arr of size n is defined as follows: Each element in arr is in the inclusive range [1, m]. Exactly k indices i (where 1 <= i < n) satisfy the condition arr[i - 1] == arr[i]. Return …

    hard