BackmediumArrays Zomato

Alternate Color Swapping Solution

Problem Statement

You have an array of integers that represents a sequence of alternating light blue and white squares on a wall...

Example 1
Input
{"arr":[1,2,3,4,5],"k":2}
Output
[3,0,5,2,7]
Example 2
Input
{"arr":[-1,0,1],"k":1}
Output
[0,-1,2]

Constraints

  • The input array will have an even number of elements.
  • The input array will always start and end with a light blue square (represented by 1).
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free