全站内容
Calf
这里收录 Calf 在 GoCalf 上的文章、笔记与其他内容。
2554. Maximum Number of Integers to Choose From a Range I
#Problem You are given an integer array banned and two integers n and maxSum. You are choosing some number of integers following the below rules: The chosen integers have to be in the range [1, n]. Each integer can be chosen at most once. …
2558. Take Gifts From the Richest Pile
#Problem You are given an integer array gifts denoting the number of gifts in various piles. Every second, you do the following: Choose the pile with the maximum number of gifts. If there is more than one pile with the maximum number of …
2559. Count Vowel Strings in Ranges
#Problem You are given a 0-indexed array of strings words and a 2D array of integers queries. Each query queries[i] = [lᵢ, rᵢ] asks us to find the number of strings present in the range lᵢ to rᵢ (both inclusive) of words that start and end …
2577. Minimum Time to Visit a Cell In a Grid
#Problem You are given a m x n matrix grid consisting of non-negative integers where grid[row][col] represents the minimum time required to be able to visit the cell (row, col), which means you can visit the cell (row, col) only when the …
2593. Find Score of an Array After Marking All Elements
#Problem You are given an array nums consisting of positive integers. Starting with score = 0, apply the following algorithm: Choose the smallest integer of the array that is not marked. If there is a tie, choose the one with the smallest …
2595. Number of Even and Odd Bits
#Problem You are given a positive integer n. Let even denote the number of even indices in the binary representation of n with value 1. Let odd denote the number of odd indices in the binary representation of n with value 1. Note that bits …
26. Remove Duplicates from Sorted Array
#Problem Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same. Then return the number of …
2608. Shortest Cycle in a Graph
#Problem There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1. The edges in the graph are represented by a given 2D integer array edges, where edges[i] = [uᵢ, vᵢ] denotes an edge between vertex uᵢ …
2657. Find the Prefix Common Array of Two Arrays
#Problem You are given two 0-indexed integer permutations A and B of length n. A prefix common array of A and B is an array C such that C[i] is equal to the count of numbers that are present at or before the index i in both A and B. Return …
2658. Maximum Number of Fish in a Grid
#Problem You are given a 0-indexed 2D matrix grid of size m x n, where (r, c) represents: A land cell if grid[r][c] = 0, or A water cell containing grid[r][c] fish, if grid[r][c] > 0. A fisher can start at any water cell (r, c) and can do …