Find the Sequence

Company: UKG_15sep

Difficulty: medium

Problem Statement

Find the Sequence Problem Description In a game you are given a string direction of length n . Every character is either 'L' (left) or 'R' (right). A line segment of length 2^n covers the interval [0, 2^n] . The player takes n turns, numbered 1 to n . In turn k : The player places the number k at the center point of the current segment. If the k -th character of direction is 'L' , the player moves left: the right half of the current segment is eliminated and the left half becomes the current segment. If the k -th character of direction is 'R' , the player moves right: the left half of the current segment is eliminated and the right half becomes the current segment. After all n turns, n numbers lie on the original segment, each at a different point. Return the numbers in the order of their points, from left to right. Function Description Complete the function findNumberSequence in the editor below. findNumberSequence(direction) has the following parameter: string direction : a string of