India’s Best Job Seekers and Training Platform Forums Java Problems set You have L, a list containing some digits (0 to 9)…

  • You have L, a list containing some digits (0 to 9)…

  • Akash 

    Administrator
    at

    You have L, a list containing some digits (0 to 9). Write a function answer(L) which finds the largest number that can be made from some or all of these digits and is divisible by 3. If it is not possible to make such a number, return 0 as the answer. L will contain anywhere from 1 to 9 digits. The same digit may appear multiple times in the list, but each element in the list may only be used once.

    {{

    Test cases

    ==========

    Inputs:

    (int list) l = [3, 1, 4, 1]

    Output:

    (int) 4311

    Inputs:

    (int list) l = [3, 1, 4, 1, 5, 9]

    Output:

    (int) 94311

    }}

Log in to reply.

Original Post
0 of 0 posts June 2018
Now
KodNest Training New Batch is starting on 02nd November 2020. Attend one week free demo classes.Register Now

New Report

Close