FastPrepCheck a Password Against a Supplied Policy
Problems/Check a Password Against a Supplied Policy

Check a Password Against a Supplied Policy

Walmart logoWalmart● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The named password-check task matches at about 60%. The report does not give its original validation rules. The minimum length, three optional ASCII class checks, the printable-character range, the empty-input behavior and the limits are our choices. They are not the separate later report of five unspecified conditions. We wrote all the complete examples.

Return whether password satisfies the policy supplied by minimumLength, requireLowercase, requireUppercase and requireDigit.

For this exercise, assume the password contains only printable ASCII characters, with codes 32 through 126. Its length must be at least minimumLength. For each flag set to true, the password must also contain at least one character of that type: lowercase a through z, uppercase A through Z, or digit 0 through 9. A flag set to false adds no requirement.

For this exercise, assume other printable characters, including spaces and punctuation, are allowed and count toward length; they satisfy none of those three classes. Return true exactly when every enabled requirement passes. An empty password passes only when the minimum is zero and all class flags are false. Do not modify the input.

Function

checkPassword(password: String, minimumLength: int, requireLowercase: boolean, requireUppercase: boolean, requireDigit: boolean) → boolean

Examples

Example 1

password = "aA0"minimumLength = 3requireLowercase = truerequireUppercase = truerequireDigit = truereturn = true

The length is three and the password contains a lowercase letter, an uppercase letter and a digit.

Example 2

password = "hello"minimumLength = 5requireLowercase = truerequireUppercase = truerequireDigit = falsereturn = false

The length and lowercase check pass, but the enabled uppercase requirement fails.

Example 3

password = ""minimumLength = 0requireLowercase = falserequireUppercase = falserequireDigit = falsereturn = true

An empty string meets the zero minimum and has no enabled class checks.

Constraints

  • For this exercise, assume 0 <= password.length <= 500.
  • For this exercise, assume 0 <= minimumLength <= 500.
  • Every password character is printable ASCII, from code 32 through 126.
  • The three class parameters are Boolean flags.

More Walmart Phone Screen questions

  • Count Months Starting on SundayPHONE SCREEN · Seen Aug 2026
  • Longest Even-Length WordPHONE SCREEN · Seen Aug 2026
  • Range ModulePHONE SCREEN · Seen Aug 2026
  • Meeting Rooms IIPHONE SCREEN · Seen Aug 2026
  • Sort Real Number StringsPHONE SCREEN · Seen Jan 2026
  • Convert a Restricted Function to an Arrow FunctionPHONE SCREEN · Seen Jun 2025
  • Repair One Missing Function Punctuation CharacterPHONE SCREEN · Seen Jun 2025
  • Can the Singer Perform the Song?PHONE SCREEN · Seen Mar 2025
  • Rooms With Two Other Entrances and a Treasure SuccessorPHONE SCREEN · Seen Mar 2025
  • First Dictionary Word from Note LettersPHONE SCREEN · Seen Aug 2022

Similar questions at other companies

  • Run-Length Encoding and DecodingAirbnb · PHONE SCREENAirbnb interview questions
  • Straight-Line Word SearchReddit · PHONE SCREENReddit interview questions
  • Search and Format ContactsAdyen · PHONE SCREENAdyen interview questions
  • Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
  • Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesStripe · PHONE SCREENStripe interview questions
  • Valid ParenthesesByteDance · PHONE SCREENByteDance interview questions
  • Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
  • Check if a String Is a PalindromeCisco · PHONE SCREENCisco interview questions
  • Halfway Course in a Single TrackCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Longest Common PrefixKotak Mahindra Bank · PHONE SCREEN · ONSITE INTERVIEWKotak Mahindra Bank interview questions
All Walmart interview questionsSee Walmart hiring insights
Saved
class Solution {
    public boolean checkPassword(String password, int minimumLength, boolean requireLowercase, boolean requireUppercase, boolean requireDigit) {
        // Write your code here.
        return false;
    }

}
Checking account…