Biggest Number From Digits
Learn this problemProblem statement
There is an array, named 'digits', consisting of N digits. Choose at most three digits (not necessarily adjacent) and merge them into a new integer without changing the order of the digits. What is the biggest number that can be obtained this way?
Write a function:
biggestNumberFromDigits
that, given an array of N digits, returns the biggest number that can be built.
Examples:
- Given digits = [7, 2, 3, 3, 4, 9], the function should return 749.
- Given digits = [0, 0, 5, 7], the function should return 57.
Assume that:
- N is an integer within the range [3..50];
- each element of array named 'digits', is an integer within the range [0..9].
In your solution, focus on correctness. The performance of your solution will not be the focus of the assessment.
Memo 🐌 On the source image it says the question is an "exercise", I've never done Google assessment before, so I am not sure if it is just a warm up exercie before the actual test.
Function
biggestNumberFromDigits(digits: int[]) → intExamples
Example 1
digits = [7, 2, 3, 3, 4, 9]return = 749Example 2
digits = [0, 0, 5, 7]return = 57Constraints
- N is an integer within the range [3..50].
- Each element of array named 'digits', is an integer within the range [0..9].
More Google problems
- Longest Subarray with Sum at Most KOA · Seen Jul 2026
- Count Prefix Matches in a Sorted ArrayONSITE INTERVIEW · Seen Jul 2026
- Decode StringONSITE INTERVIEW · Seen Jul 2026
- Phone Keypad Letter CombinationsONSITE INTERVIEW · Seen Jul 2026
- Split a Log Outside QuotesONSITE INTERVIEW · Seen Jul 2026
- Ad Score Scheduler With DelayONSITE INTERVIEW · Seen Jul 2026
- Alternating-Color Binary Tree RootsONSITE INTERVIEW · Seen Jul 2026
- Route Pattern MatcherONSITE INTERVIEW · Seen Jul 2026