Given a string of lowercase alphabets **A** of size **N** and two integers **B** and **C**.

You have to perform **B** swaps, Where **i’th** swap = **swap(A[i % N], A[(i + C) % N])**.

Return the final string **A** after **B** swaps.

**NOTE:** String **A** is **0** based indexed.

**NOTE:** Swaps are **0** based indexed.

**Input Format**

```
The first argument given is the string A.
The second argument given is the string representation of integer B.
The third argument given is the integer C.
```

**Output Format**

```
Return the final string A after B swaps.
```

**Constraints**

```
1 <= N <= 10^5
1 <= B <= 10^11
1 <= C <= N
```

**For Example**

```
Input 1:
A = "interviewbit"
B = "3"
C = 3
Output 1:
A = "ervintiewbit"
Explaination 1:
After swap 0: swap(A[0%12], A[(0 + 3)%12]) A = "entirviewbit"
After swap 1: swap(A[1%12], A[(1 + 3)%12]) A = "ertinviewbit"
After swap 2: swap(A[2%12], A[(2 + 3)%12]) A = "ervintiewbit"
After swap 3: swap(A[3%12], A[(3 + 3)%12]) A = "ervintiewbit"
Input 2:
A = "raman"
B = "1"
C = 4
Output 2:
"anmar"
Explaination 2:
After swap 0: swap(A[0%5], A[(0 + 4)%5]) A = "namar"
After swap 1: swap(A[1%5], A[(1 + 4)%5]) A = "anmar"
```

NOTE:You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.

Sign Up

to access hints and editorial solutions for**KEEP SWAPPING 2**

to access hints and editorial solutions for

Loading...