PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Karat

Validate password and list rule violations

Last updated: May 25, 2026

Quick Overview

This question evaluates string-processing and input-validation skills, including case-insensitive substring detection, character class checks, pattern matching for special symbols, and handling edge cases like consecutive character limits.

  • medium
  • Karat
  • Coding & Algorithms
  • Software Engineer

Validate password and list rule violations

Company: Karat

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem You are given a password string `p`. Validate it against a set of rules and return **all** rules that the password violates. ## Rules 1. **Length** must be **greater than 15** characters. 2. Must **not** contain the substring **"password"** (case-insensitive). For example, `"MyPassWord123"` violates this rule. 3. Must contain **at least one uppercase** letter (`A-Z`) and **at least one lowercase** letter (`a-z`). 4. Must contain **at least one** character from a given set of **three special symbols** (the set will be provided by the interviewer; e.g., `{!, @, #}`). 5. **No character** may repeat **more than 4 times consecutively** (e.g., `"aaaaa"` violates; `"aaaa"` is OK). ## Input - A string `p`. - A set/list of exactly 3 allowed special characters. ## Output - A list of violated rules (as strings or codes) in a deterministic order (e.g., rule number order). ## Notes - If the password is fully compliant, return an empty list. - Treat the "password" check as case-insensitive.

Quick Answer: This question evaluates string-processing and input-validation skills, including case-insensitive substring detection, character class checks, pattern matching for special symbols, and handling edge cases like consecutive character limits.

Related Interview Questions

  • Implement obstacle-course run statistics - Karat (medium)
  • Join tables to map userId to name - Karat (medium)
Karat logo
Karat
Jan 22, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
7
0

Problem

You are given a password string p. Validate it against a set of rules and return all rules that the password violates.

Rules

  1. Length must be greater than 15 characters.
  2. Must not contain the substring "password" (case-insensitive). For example, "MyPassWord123" violates this rule.
  3. Must contain at least one uppercase letter ( A-Z ) and at least one lowercase letter ( a-z ).
  4. Must contain at least one character from a given set of three special symbols (the set will be provided by the interviewer; e.g., {!, @, #} ).
  5. No character may repeat more than 4 times consecutively (e.g., "aaaaa" violates; "aaaa" is OK).

Input

  • A string p .
  • A set/list of exactly 3 allowed special characters.

Output

  • A list of violated rules (as strings or codes) in a deterministic order (e.g., rule number order).

Notes

  • If the password is fully compliant, return an empty list.
  • Treat the "password" check as case-insensitive.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Karat•More Software Engineer•Karat Software Engineer•Karat Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.