Problem · String

Valid String Check

Learn this problem
EasyUberOA
See Uber hiring insights

Problem statement

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.
  • Function

    isValidString(s: String) → int

    Examples

    Example 1

    s = "771"return = 1
    :)

    Example 2

    s = "777"return = 1
    :)

    Example 3

    s = "123777"return = 1
    :)

    Example 4

    s = "12345"return = 0
    :)

    Example 5

    s = "71"return = 0
    :)

    Example 6

    s = "171"return = 0
    :)

    Example 7

    s = "70"return = 0
    :)

    More Uber problems

    drafts saved locally
    public int isValidString(String s) {
      // write your code here
    }
    
    s"771"
    expected1
    checking account