Close

Generating next bigger palindrome of a number

Given a number, how do we generate a smallest number which is greater than the given number and is a palindrome?Consider the following examplesInput    Output3         49         1113        22767       777594       595898       909999       1001Here is the solution approach. This problem has multiple cases to be considered.Case 1: If all the digits in the number are ‘9’, the output…

GCD queries

This problem is from Codechef January challenge. Click on the link to try this problem on your own. The problem statement is as follows. Given an array of size N and two indices L and R. We need to find the GCD (Greatest Common Divisor) of all the array elements except in the range [L,R].…