All Posts
Leetcode 1733: Minimum Number of People to Teach
In a social network consisting of multiple users and their friendships, users can communicate with each other only if they share a common language. You are given a list of languages each user knows and a list of friendships between users. Your task is to teach a single language to some users such that all the users in each friendship can communicate. The goal is to minimize the number of users you need to teach the new language.
Leetcode 1734: Decode XORed Permutation
You are given an array encoded of length n - 1, which represents the XOR of consecutive elements of a permutation of the first n integers. Your task is to decode the encoded array and return the original permutation perm of size n.
Leetcode 1738: Find Kth Largest XOR Coordinate Value
You are given a 2D matrix of size m x n, consisting of non-negative integers. You are also given an integer k. The value of coordinate (a, b) in the matrix is the XOR of all the values from matrix[0][0] to matrix[a][b] (inclusive), where 0 <= a < m and 0 <= b < n (0-indexed). Your task is to find the kth largest value (1-indexed) among all the XOR values of matrix coordinates.
Leetcode 1743: Restore the Array From Adjacent Pairs
You are given an integer array nums with unique elements, but you have forgotten it. However, you do remember every pair of adjacent elements in nums. You are given a 2D integer array adjacentPairs where each adjacentPairs[i] = [ui, vi] indicates that the elements ui and vi are adjacent in nums. Your task is to reconstruct the original array nums using these adjacent pairs. There could be multiple valid solutions, so return any one of them.
Leetcode 1744: Can You Eat Your Favorite Candy on Your Favorite Day?
You are given an array candiesCount where each element represents the number of candies of a particular type. You are also given a set of queries, each asking whether it’s possible to eat a candy of a certain type on a specific day without exceeding a daily candy limit. You must follow these game rules:
- You start eating candies on day 0.
- You cannot eat candies of type
iuntil you have eaten all candies of typei-1. - You must eat at least one candy per day.
Your task is to return an array of booleans where each element indicates whether it’s possible to eat a candy of the specified type on the given day, subject to the daily cap.