A couple of online assesment questions and solutions that are being asked in Google OA (US Based Position) - HackerRank
Question 1
One fragment of a given integer N can be selected and its digits reversed (replaced with a right to left version of themselves). What is the maximum number that can beobtained this way from integer N?
Write a function:
class Solution { public int solution(int N); }
that, given an integer 1 <= N <= 1,000,000,000, returns the greatest integer that can be created by reversing a subset of its digits.
Examples:
• Given N = 5340, [he answer is 5430. Fragment "34" can be reversed to "43".
• Given N = 2043, the answer is 4023. Fragment "204" can be reversed to "402"
• Given N = 620, the answer is 620. There is no need to reverse any fragment.
Assumptions:
• 1 <= N <= 1.000.000.000.