close nav

close nav

Thread: Logical Program Asked in Wipro

Forum : Problem Solving   11 Oct, 2021
User Image
Ankit123

Newbie

Joined: 8 Dec, 2017

Points: 100

Threads: 42

Posts: 38

Logical Program Asked in Wipro

| Quote Date : 11 Oct, 2021    Views:485    

Program the follow question below in any language

Three people are playing a game in which one person is selected first, the second person gives the selected person a number N, and the third person also gives the selected person a number M
The selected person has to maximize the number given by the second person in a way that:
1. (S)he can maximize the number given by the second person only by swapping the
adjacent two digits of the number
2. The number that the third person gives is the maximum number of swaps allowed.

Find the maximum number that the selected person can achieve.
Input Specification:
input1: The number N

input2: The number M

Note: The number N is given in the string format as input.

output specification : the maximum number the person can achieve in M swaps

Example1:

input1: 1234

input2: 2

Output: 3124 

Comments

User Image
Ankit123

Newbie

Joined : 8 Dec, 2017

Points : 100

Threads: 42

Posts: 38

User Image
Ankit123

Newbie

Joined : 8 Dec, 2017

Points : 100

Threads: 42

Posts: 38

Re: Logical Program Asked in Wipro

Reply Date : 11 Oct, 2021
Load More

No More Comments