All Posts

Leetcode 2325: Decode the Message

Given a cipher key and a secret message, decode the message by replacing each letter with the corresponding letter in the alphabet based on the first appearance of each letter in the key. Spaces in the message remain unchanged.

Leetcode 2336: Smallest Number in Infinite Set

You have a set containing all positive integers starting from 1. You need to implement a class SmallestInfiniteSet that has the following methods:

  • SmallestInfiniteSet() Initializes the set to contain all positive integers starting from 1.
  • popSmallest() Removes and returns the smallest integer in the set.
  • addBack(int num) Adds a positive integer num back into the set, if it’s not already present in the set.

Leetcode 2341: Maximum Number of Pairs in Array

You are given an integer array nums. In one operation, you can choose two integers in the array that are the same and remove both. The operation is repeated as many times as possible. Return an array where the first element is the number of pairs formed, and the second element is the number of leftover integers.

Leetcode 2342: Max Sum of a Pair With Equal Sum of Digits

You are given an array nums of positive integers. You need to find two indices i and j such that i != j, and the sum of digits of the numbers nums[i] and nums[j] is the same. Return the maximum sum of nums[i] + nums[j] that you can obtain over all valid pairs of indices. If no such pair exists, return -1.

Leetcode 2347: Best Poker Hand

You are given an integer array ranks and a character array suits. These represent a set of 5 playing cards, where each card has a rank (from 1 to 13) and a suit (one of ‘a’, ‘b’, ‘c’, or ’d’). Determine the best possible poker hand you can make from the cards.

Leetcode 2349: Design a Number Container System

Design a number container system that allows inserting or replacing a number at a specific index and finding the smallest index for a given number.