FastPrepFind Largest Number (Google Early Career)

Find Largest Number (Google Early Career)

Google logoGoogle● EasyFULLTIMEOA

Problem statement

You are given an array of decimal digits with length at least 3. Choose three elements while preserving their original left-to-right order and concatenate them into a three-digit integer.

Return the largest integer that can be formed. The visible example establishes the order-preserving requirement: from [7,4,3,8,2], the answer is 782.

Function

findLargestNumber(nums: int[]) → int

Examples

Example 1

nums = [7, 4, 3, 8, 2]return = 782

🐹🐹

Constraints

  • 3 <= nums.length <= 10^5
  • 0 <= nums[i] <= 9

More Google problems

See Google hiring insights
Saved
public int findLargestNumber(int[] nums) {
  // write your code here
}
nums[7, 4, 3, 8, 2]
expected782
Checking account…