All Posts

Leetcode 2149: Rearrange Array Elements by Sign

You are given an integer array ’nums’ of even length consisting of an equal number of positive and negative integers. Rearrange the array such that every consecutive pair of integers has opposite signs, the order of integers with the same sign is preserved, and the array begins with a positive integer.

Leetcode 2150: Find All Lonely Numbers in the Array

You are given an integer array ’nums’. A number ‘x’ is lonely if it appears exactly once and neither ‘x - 1’ nor ‘x + 1’ exist in the array. Return all lonely numbers in the array.

Leetcode 2155: All Divisions With the Highest Score of a Binary Array

You are given a binary array ’nums’. You can divide the array at any index ‘i’ into two parts: ’numsleft’ (before index ‘i’) and ’numsright’ (from index ‘i’ to the end). The division score is the sum of zeros in ’numsleft’ and ones in ’numsright’. Your task is to find all indices where the division score is the highest.

Leetcode 2161: Partition Array According to Given Pivot

You are given an integer array ’nums’ and a value ‘pivot’. Your task is to rearrange the elements in ’nums’ such that all elements less than ‘pivot’ appear before any element greater than ‘pivot’, and all elements equal to ‘pivot’ appear between the elements less than and greater than ‘pivot’. The relative order of the elements less than and greater than ‘pivot’ should be preserved.

Leetcode 2165: Smallest Value of the Rearranged Number

You are given an integer ’num’. Your task is to rearrange the digits of ’num’ such that its value is minimized, with the constraint that the number must not contain any leading zeros. The sign of the number should not change after rearranging the digits.

Leetcode 2166: Design Bitset

You are tasked with implementing a Bitset class that supports operations such as setting bits, clearing bits, flipping all bits, and querying the state of the bits (whether all bits are set to 1, at least one bit is set to 1, etc.).