Physics, asked by Anonymous, 1 day ago

Max num 1 Auto complete ready! Given a number N. with the help of digits of that number you need to make another number by swapping any values such that the number obtained is maximum possible number from those digits. Print the maximum value obtained.

Nobody gave me pizza on my alt acc
Anybody here
Who can give me and Mr.Quack free pizza?​

Answers

Answered by itzmecutejennei
1

Answer:

Create an array rightMax[]. rightMax[i] contains the index of the greatest digit which is on the right side of num[i] and also greater than num[i]. If no such digit exists then rightMax[i] = -1. Now, traverse the rightMax[] array from i = 0 to n-1(where n is the total number of digits in num), and find the first element having rightMax[i] != -1. Perform the swap(num[i], num[rightMax[i]]) operation and break.

hope it helps you pls mark me as brainlist pls ❤️❤️

Answered by s02371joshuaprince47
0

Answer:

//if you want to print it right away: 4. cout << fmax(x , y);. 5. //if you want to store it: ... C++ answers related to “how to find maximum value in c++”.

Similar questions