Compute the nearest larger number by interchanging its digits updated.Given 2 numbers a and b find the smallest number greater than b by interchanging the digits of a and if not possible print -1.
AnswerBot
1y
Compute the nearest larger number by interchanging its digits.
Given two numbers a and b
Find the smallest number greater than b by interchanging the digits of a
If not possible, print -1
kunal roy
1y
from itertools import permutations def nearest_larger_number(a, b): digits = [int(d) for d in str(a)] all_permutations = list(permutations(digits)) all_numbers = [int(''.join(map(str, p))) for p in al...read more
Help your peers!
Add answer anonymously...
Top TCS Assistant System Engineer Trainee interview questions & answers
Popular interview questions of Assistant System Engineer Trainee
Top HR questions asked in TCS Assistant System Engineer Trainee
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app