全站内容
Calf
这里收录 Calf 在 GoCalf 上的文章、笔记与其他内容。
2661. First Completely Painted Row or Column
#Problem You are given a 0-indexed integer array arr, and an m x n integer matrix mat. arr and mat both contain all the integers in the range [1, m * n]. Go through each index i in arr starting from index 0 and paint the cell in mat …
268. Missing Number
#Problem Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. https://leetcode.com/problems/missing-number/ Example 1: Input: nums = [3,0,1] Output: 2 …
2683. Neighboring Bitwise XOR
#Problem A 0-indexed array derived with length n is derived by computing the bitwise XOR (⊕) of adjacent values in a binary array original of length n. Specifically, for each index i in the range [0, n - 1]: If i = n - 1, then derived[i] = …
2698. Find the Punishment Number of an Integer
#Problem Given a positive integer n, return the punishment number of n. The punishment number of n is defined as the sum of the squares of all integers i such that: 1 <= i <= n The decimal representation of i * i can be partitioned into …
2699. Modify Graph Edge Weights
#Problem You are given an undirected weighted connected graph containing n nodes labeled from 0 to n - 1, and an integer array edges where edges[i] = [aᵢ, bᵢ, wᵢ] indicates that there is an edge between nodes aᵢ and bᵢ with weight wᵢ. Some …
2717. Semi-Ordered Permutation
#Problem You are given a 0-indexed permutation of n integers nums. A permutation is called semi-ordered if the first number equals 1 and the last number equals n. You can perform the below operation as many times as you want until you make …
2762. Continuous Subarrays
#Problem You are given a 0-indexed integer array nums. A subarray of nums is called continuous if: Let i, i + 1, …, j be the indices in the subarray. Then, for each pair of indices i <= i₁, i₂ <= j, 0 <= |nums[i₁] - nums[i₂]| <= 2. Return …
2779. Maximum Beauty of an Array After Applying Operation
#Problem You are given a 0-indexed array nums and a non-negative integer k. In one operation, you can do the following: Choose an index i that hasn’t been chosen before from the range [0, nums.length - 1]. Replace nums[i] with any integer …
2809. Minimum Time to Make Array Sum At Most x
#Problem You are given two 0-indexed integer arrays nums1 and nums2 of equal length. Every second, for all indices 0 <= i < nums1.length, value of nums1[i] is incremented by nums2[i]. After this is done, you can do the following operation: …
2825. Make String a Subsequence Using Cyclic Increments
#Problem You are given two 0-indexed strings str1 and str2. In an operation, you select a set of indices in str1, and for each index i in the set, increment str1[i] to the next character cyclically. That is 'a' becomes 'b', 'b' becomes 'c', …