All Posts

Leetcode 3136: Valid Word

You are given a string word. The word is considered valid if it satisfies the following conditions:

  1. It contains at least 3 characters.
  2. It contains only digits (0-9) and English letters (both uppercase and lowercase).
  3. It must include at least one vowel (‘a’, ’e’, ‘i’, ‘o’, ‘u’ and their uppercase counterparts).
  4. It must include at least one consonant (an English letter that is not a vowel).

Return true if the word is valid, otherwise return false.

Leetcode 3146: Permutation Difference between Two Strings

You are given two strings, s and t, where every character occurs at most once in both strings and t is a permutation of s. The permutation difference between s and t is defined as the sum of the absolute differences between the index of each character in s and the index of the occurrence of the same character in t. Your task is to compute the permutation difference between s and t.

Leetcode 3162: Find the Number of Good Pairs I

You are given two integer arrays nums1 and nums2 of lengths n and m respectively, and a positive integer k. A pair (i, j) is called good if nums1[i] is divisible by nums2[j] * k (0 <= i <= n - 1, 0 <= j <= m - 1). Your task is to return the total number of good pairs.

Leetcode 3168: Minimum Number of Chairs in a Waiting Room

You are given a string s representing a sequence of events where each character is either ‘E’ (a person enters the waiting room) or ‘L’ (a person leaves the waiting room). The waiting room starts empty. Simulate the events and determine the minimum number of chairs required to ensure there is always a chair available for every person who enters the room.

Leetcode 3178: Find the Child Who Has the Ball After K Seconds

You are given two positive integers, n and k. There are n children numbered from 0 to n - 1, standing in a queue from left to right. Initially, child 0 holds a ball and the direction of passing the ball is towards the right. After each second, the child holding the ball passes it to the next child in the queue. If the ball reaches the first or last child, the direction of passing the ball reverses. You need to determine which child will have the ball after k seconds.

Leetcode 3190: Find Minimum Operations to Make All Elements Divisible by Three

You are given an array of integers nums. In each operation, you can either add or subtract 1 from any element in nums. Your task is to determine the minimum number of operations required to make all elements of nums divisible by 3.