GoCalf Calf 的自留地 · 昙花一现

全站内容

Calf

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

  • 3242. Design Neighbor Sum Service

    Coding

    #Problem You are given a n x n 2D array grid containing distinct elements in the range [0, n² - 1]. Implement the NeighborSum class: NeighborSum(int [][]grid) initializes the object. int adjacentSum(int value) returns the sum of elements …

    easy
  • 3243. Shortest Distance After Road Addition Queries I

    Coding

    #Problem You are given an integer n and a 2D integer array queries. There are n cities numbered from 0 to n - 1. Initially, there is a unidirectional road from city i to city i + 1 for all 0 <= i < n - 1. queries[i] = [uᵢ, vᵢ] represents …

    medium
  • 3244. Shortest Distance After Road Addition Queries II

    Coding

    #Problem You are given an integer n and a 2D integer array queries. There are n cities numbered from 0 to n - 1. Initially, there is a unidirectional road from city i to city i + 1 for all 0 <= i < n - 1. queries[i] = [uᵢ, vᵢ] represents …

    hard
  • 3248. Snake in Matrix

    Coding

    #Problem There is a snake in an n x n matrix grid and can move in four possible directions. Each cell in the grid is identified by the position: grid[i][j] = (i * n) + j. The snake starts at cell 0 and follows a sequence of commands. You …

    easy
  • 3249. Count the Number of Good Nodes

    Coding

    #Problem There is an undirected tree with n nodes labeled from 0 to n - 1, and rooted at node 0. You are given a 2D integer array edges of length n - 1, where edges[i] = [aᵢ, bᵢ] indicates that there is an edge between nodes aᵢ and bᵢ in …

    medium
  • 3250. Find the Count of Monotonic Pairs I

    Coding

    #Problem You are given an array of positive integers nums of length n. We call a pair of non-negative integer arrays (arr1, arr2) monotonic if: The lengths of both arrays are n. arr1 is monotonically non-decreasing, in other words, arr1[0] …

    hard
  • 3251. Find the Count of Monotonic Pairs II

    Coding

    跟 3250. Find the Count of Monotonic Pairs I 一模一样,只不过 nums[i] 的上限从 50 增加到 1000。 https://leetcode.cn/problems/find-the-count-of-monotonic-pairs-ii/ 直接用上次的代码似乎问题不大。

    hard
  • 3254. Find the Power of K-Size Subarrays I

    Coding

    #Problem You are given an array of integers nums of length n and a positive integer k. The power of an array is defined as: Its maximum element if all of its elements are consecutive and sorted in ascending order. -1 otherwise. You need to …

    medium
  • 3255. Find the Power of K-Size Subarrays II

    Coding

    跟 3254. Find the Power of K-Size Subarrays I 一模一样,只不过 n 的上限从 500 增加到 10⁵。 https://leetcode.cn/problems/find-the-power-of-k-size-subarrays-ii/

    medium
  • 3258. Count Substrings That Satisfy K-Constraint I

    Coding

    #Problem You are given a binary string s and an integer k. A binary string satisfies the k-constraint if either of the following conditions holds: The number of 0’s in the string is at most k. The number of 1’s in the string is at most k. …

    easy