Showing 3 questions
Find the number of contiguous subarrays in a given array whose least common multiple (LCM) is equal to a target value K.
#1. Number of Subarrays With LCM Equal to K
Two players alternate removing colored pieces from a line. Determine who wins if both neighbors of a piece are the same color, and players try to maximize their moves.
#2. Remove Colored Pieces if Both Neighbors are the Same Color
Design a data structure that supports insertion, deletion, and random element retrieval, all in constant time on average. You'll need to handle edge cases carefully to achieve O(1) complexity.
#3. Insert Delete GetRandom O(1)