FastPrepFastPrep
Problem Brief

Valid String Check

OA
See Uber online assessment and hiring insights

Given a string, check if it is valid (return 1 :) or not (return 0 :). A valid string must:

  • Be divisible by 3 (interpreted as the numeric value of the string is divisible by 3).
  • Contain the digit '7' at least twice.
  • 1Example 1

    Input
    s = "771"
    Output
    1
    Explanation
    :)

    2Example 2

    Input
    s = "777"
    Output
    1
    Explanation
    :)

    3Example 3

    Input
    s = "123777"
    Output
    1
    Explanation
    :)

    4Example 4

    Input
    s = "12345"
    Output
    0
    Explanation
    :)

    5Example 5

    Input
    s = "71"
    Output
    0
    Explanation
    :)

    6Example 6

    Input
    s = "171"
    Output
    0
    Explanation
    :)

    7Example 7

    Input
    s = "70"
    Output
    0
    Explanation
    :)
    public int isValidString(String s) {
      // write your code here
    }
    
    Input

    s

    "771"

    Output

    1

    Sign in to submit your solution.