全站内容
Calf
这里收录 Calf 在 GoCalf 上的文章、笔记与其他内容。
2425. Bitwise XOR of All Pairings
#Problem You are given two 0-indexed arrays, nums1 and nums2, consisting of non-negative integers. There exists another array, nums3, which contains the bitwise XOR of all pairings of integers between nums1 and nums2 (every integer in nums1 …
2429. Minimize XOR
#Problem Given two positive integers num1 and num2, find the positive integer x such that: x has the same number of set bits as num2, and The value x XOR num1 is minimal. Note that XOR is the bitwise XOR operation. Return the integer x. The …
2466. Count Ways To Build Good Strings
#Problem Given the integers zero, one, low, and high, we can construct a string by starting with an empty string, and then at each step perform either of the following: Append the character '0' zero times. Append the character '1' one …
2467. Most Profitable Path in a Tree
#Problem There is an undirected tree with n nodes labeled from 0 to n - 1, 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 the …
2471. Minimum Number of Operations to Sort a Binary Tree by Level
#Problem You are given the root of a binary tree with unique values. In one operation, you can choose any two nodes at the same level and swap their values. Return the minimum number of operations needed to make the values at each level …
2490. Circular Sentence
#Problem A sentence is a list of words that are separated by a single space with no leading or trailing spaces. For example, "Hello World", "HELLO", "hello world hello world" are all sentences. Words consist of only uppercase and lowercase …
2493. Divide Nodes Into the Maximum Number of Groups
#Problem You are given a positive integer n representing the number of nodes in an undirected graph. The nodes are labeled from 1 to n. You are also given a 2D integer array edges, where edges[i] = [aᵢ, bᵢ] indicates that there is a …
2502. Design Memory Allocator
#Problem You are given an integer n representing the size of a 0-indexed memory array. All memory units are initially free. You have a memory allocator with the following functionalities: Allocate a block of size consecutive free memory …
2506. Count Pairs Of Similar Strings
#Problem You are given a 0-indexed string array words. Two strings are similar if they consist of the same characters. For example, "abca" and "cba" are similar since both consist of characters 'a', 'b', and 'c'. However, "abacba" and …
2545. Sort the Students by Their Kth Score
#Problem There is a class with m students and n exams. You are given a 0-indexed m x n integer matrix score, where each row represents one student and score[i][j] denotes the score the iᵗʰ student got in the jᵗʰ exam. The matrix score …