Problem · Array
Focus on Correctness (2024 NG)
Learn this problemProblem statement
Given an array of digits, select up to 3 digits to form a number without changing their order. Return the largest possible number.
Note - When doing the assessment, they ask you to write your own test cases :)
Function
largestNumberPossible(digits: int[]) → intExamples
Example 1
digits = [7, 2, 3, 3, 4, 9]return = 749The largest number that can be formed by selecting up to 3 digits without changing their order is 749.
Constraints
1 ≤ digits.length ≤ 10^50 ≤ digits[i] ≤ 9- The relative order of selected digits must match their order in the input array.