You are given an array changed, which may have been created by doubling each element of an original array and then shuffling the elements. Your task is to determine if changed can be converted back into the original array, where each element in the original array has its double present in changed. If changed is not a valid doubled array, return an empty array. If it is valid, return the original array.
You are given a string s consisting of n characters, where each character is either ‘X’ or ‘O’. A move consists of selecting three consecutive characters in the string and converting them all to ‘O’. If a character is already ‘O’, it remains unchanged. Determine the minimum number of moves required to convert all the characters of s to ‘O’.
Alice and Bob are playing a game with stones. The sequence of n stones has values given in an array stones. Players take turns to remove a stone. The player who removes a stone, making the sum of all removed stones divisible by 3, loses. If all stones are removed, Bob wins automatically. Determine if Alice wins or Bob wins, assuming both play optimally.
You are given two arrays: one representing the available seats in a row and the other representing the students who need to be seated. Each element in the arrays corresponds to a student’s desired seat or the position of an available seat. The task is to determine the minimum number of moves required to seat all students. A move consists of moving a student from one seat to another.
You are given a string colors consisting of two types of pieces, ‘X’ and ‘Y’, arranged in a line. Two players, Alex and Brian, play a game where they take turns removing pieces from the string. Alex moves first and can only remove a piece ‘X’ if both its neighbors are also ‘X’. Similarly, Brian can only remove a piece ‘Y’ if both its neighbors are also ‘Y’. Neither player can remove edge pieces. If a player cannot make a move, they lose. Determine whether Alex wins the game if both players play optimally.
You are given a string representing hamster positions. The string consists of ‘H’ for a hamster and ‘.’ for an empty space. You must place food buckets in empty positions such that all hamsters are fed. A hamster is fed if a food bucket is placed at one of its adjacent positions. Your task is to return the minimum number of food buckets required to feed all the hamsters. If it is impossible, return -1.