All Posts

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 2154: Keep Multiplying Found Values by Two

You are given an array of integers ’nums’ and an integer ‘original’. Start with the number ‘original’ and search for it in the array. If found, multiply it by two. Repeat this process until ‘original’ is no longer found in ’nums’. Return the final value of ‘original’.

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 2164: Sort Even and Odd Indices Independently

You are given a 0-indexed integer array ’nums’. Your task is to rearrange the elements of ’nums’ by sorting the values at odd indices in non-increasing order and the values at even indices in non-decreasing order. Return the rearranged array.

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.).