BackmediumArrays Swiggy

Galactic Message Relay Solution

Problem Statement

Given a list of messages and a number of satellite shifts, cyclically rotate the messages through the satellites that many times to the right and return the resulting list of messages.

Example 1
Input
['SPACE', 'HELLO', 'GALAXY', 'STATION'], 1
Output
['SPACE', 'STATION', 'HELLO', 'GALAXY']

Explanation: Step 1: Given the input ['SPACE', 'HELLO', 'GALAXY', 'STATION'] and the number of shifts 1. Step 2: Calculate the effective shift as 1 % 4 = 1. Step 3: Rotate the array to the right by 1 position. Step 4: The resulting array is ['SPACE', 'STATION', 'HELLO', 'GALAXY'].

Example 2
Input
['MARS', 'EARTH', 'VENUS'], 5
Output
['MARS', 'EARTH', 'VENUS']

Explanation: Step 1: Given the input ['MARS', 'EARTH', 'VENUS'] and the number of shifts 5. Step 2: Calculate the effective shift as 5 % 3 = 2. Step 3: Rotate the array to the right by 2 positions. Step 4: The resulting array is ['MARS', 'EARTH', 'VENUS'].

Constraints

  • 1 <= number of messages <= 100
  • 0 <= number of shifts <= 1000
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