All Posts

Leetcode 2358: Maximum Number of Groups Entering a Competition

You are given a positive integer array grades which represents the grades of students. Your goal is to group these students into ordered non-empty groups where:

  1. The sum of the grades in the i-th group is less than the sum of the grades in the (i + 1)-th group.
  2. The number of students in the i-th group is less than the number of students in the (i + 1)-th group. Return the maximum number of groups that can be formed.

Leetcode 2364: Count Number of Bad Pairs

You are given a 0-indexed integer array, nums. A pair of indices (i, j) is considered a ‘bad pair’ if i < j and j - i is not equal to nums[j] - nums[i]. Your task is to determine the total number of bad pairs in the array.

Leetcode 2396: Strictly Palindromic Number

An integer n is considered strictly palindromic if, for every base b between 2 and n - 2 (inclusive), the representation of n in base b is a palindrome. A number is palindromic in a base if the string representation of that number in that base reads the same forward and backward. Your task is to determine if the given integer n is strictly palindromic or not.

Leetcode 2400: Number of Ways to Reach a Position After Exactly k Steps

You are standing at a starting position startPos on an infinite number line, and you need to reach a destination endPos in exactly k steps. In each step, you can move either one position to the left or one position to the right. Your task is to find the number of different ways to reach endPos from startPos in exactly k steps. Since the number of ways can be very large, return the result modulo 10^9 + 7.

Leetcode 2409: Count Days Spent Together

Alice and Bob are traveling to Rome for separate business meetings. You are given four strings representing their travel dates: arriveAlice, leaveAlice, arriveBob, and leaveBob. Each string follows the format ‘MM-DD’, which represents the month and day of their respective travel dates. Alice will be in Rome from ‘arriveAlice’ to ’leaveAlice’, while Bob will be in the city from ‘arriveBob’ to ’leaveBob’. Your task is to calculate how many days they will both be in Rome together.

Leetcode 2413: Smallest Even Multiple

Given a positive integer ’n’, return the smallest positive integer that is a multiple of both 2 and ’n'.