Skip to content

Latest commit

 

History

History

largest_number_divisible_by_three

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Problem Description

Given a non-negative number up to 10 digits long, find the largest number that can be formed with the digits and is divisible by 3. If no number can be formed that is divisible by 3, return 0.

Input: int Output int

Examples:

  • largest_div_by_three(0) -> 0
  • largest_div_by_three(24) -> 42
  • largest_div_by_three(319) -> 93
  • largest_div_by_three(113) -> 3
  • largest_div_by_three(111) -> 111