Company: SAP Labs_5sep
Difficulty: medium
Game Piece Movement Distance Problem Description You are given an array board of length N , describing subsequent positions on a game board from left to right. Every position is either empty (represented by 0 in the array) or contains a single game piece (represented by 1). Each game piece can be moved at most once. A move means going one or more positions to either the left or the right. Pieces cannot capture (occupy another piece's position) or jump over each other. When a game piece is moved by X positions (either left or right), we say it travels distance X . Pieces can be moved in any order, but they must be moved only one at a time. What is the maximum possible distance that the game pieces can travel altogether? Write a function: int solution(vector<int> &board); that, given an array board consisting of N integers (0s and/or 1s), returns the maximum total distance the game pieces can travel altogether, under the constraint that each of them is moved at most once. Examples