The Detect Capital interview question asks you to validate if a word follows standard capitalization rules. A word is valid if:
This is a standard "Easy" screening question used by Microsoft and Bloomberg. it's a test of basic string processing and conditional logic. It evaluates whether you can handle multiple valid states cleanly and whether you consider edge cases like single-letter words or empty strings.
This problem uses String Manipulation and Case Checking. You can solve it by counting the number of uppercase letters and checking their positions.
count == length All caps (Valid).count == 0 All lowercase (Valid).count == 1 and the first letter is uppercase Capitalized (Valid).if-else statements that check character by character without a summary count.For string validation problems, try to find a mathematical way to summarize the state (like counting capitals) before jumping into complex conditional logic. It makes the code much more robust and readable.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Score of a String | Easy | Solve | |
| Delete Characters to Make Fancy String | Easy | Solve | |
| Find the Original Typed String I | Easy | Solve | |
| Valid Word | Easy | Solve | |
| Number of Segments in a String | Easy | Solve |