All Posts

Leetcode 1202: Smallest String With Swaps

You are given a string s and an array of pairs of indices pairs where each pair pairs[i] = [a, b] represents two indices in the string. You can swap the characters at any of these index pairs any number of times. Your task is to return the lexicographically smallest string that can be obtained after performing the swaps.

Leetcode 1207: Unique Number of Occurrences

Given an array of integers arr, return true if the number of occurrences of each value in the array is unique, and return false otherwise.

Leetcode 1218: Longest Arithmetic Subsequence of Given Difference

Given an integer array arr and an integer difference, find the length of the longest subsequence in arr such that the difference between each adjacent element in the subsequence equals the given difference.

Leetcode 1248: Count Number of Nice Subarrays

You are given an array of integers nums and an integer k. A subarray is considered ’nice’ if it contains exactly k odd numbers. Your task is to return the number of nice subarrays in the given array.

Leetcode 1261: Find Elements in a Contaminated Binary Tree

Given a contaminated binary tree, recover it and implement a class to search for specific values in the tree.

Leetcode 1282: Group the People Given the Group Size They Belong To

Given an array where each element represents the required size of the group for each person, group the people accordingly and return the groups. Each person must be in exactly one group.