You are given an n x n matrix where each element is an integer. The matrix is considered valid if every row and every column contains all the integers from 1 to n (inclusive). Your task is to check whether the given matrix satisfies this condition. Return true if the matrix is valid, and false otherwise.
Given two arrays of strings, startWords and targetWords, determine how many strings in targetWords can be formed by appending a letter to any string in startWords and rearranging the letters.
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.
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’.
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.).
You are given a 0-indexed array nums consisting of n positive integers. The array nums is called alternating if nums[i - 2] == nums[i] and nums[i - 1] != nums[i] for all valid i. In one operation, you can choose an index i and change nums[i] into any positive integer. Your task is to return the minimum number of operations required to make the array alternating.