Back to Browse

Detect Capital LeetCode

5 views
May 16, 2026
7:02

๐Ÿ”น Problem: Detect Capital (LeetCode) In this video, we solve a beginner-friendly string validation problem. The task is to determine whether the usage of capital letters in a word is correct. --- ๐Ÿ”น Valid Cases: 1. All letters uppercase Example: USA 2. All letters lowercase Example: leetcode 3. Only first letter uppercase Example: Google --- ๐Ÿ”น Brute Force Approach: One possible solution: - Check every possible pattern manually - Compare uppercase and lowercase letters This works but becomes lengthy. --- ๐Ÿ”น Optimized Approach: We count uppercase letters. Steps: 1. Traverse the word 2. Count uppercase letters 3. Check: - all uppercase - all lowercase - only first letter uppercase --- ๐Ÿ”น Key Idea: All valid patterns can be identified using uppercase count. --- ๐Ÿ”น Dry Run Example: word = FlaG Uppercase letters: F and G Count = 2 Invalid pattern Answer = false --- ๐Ÿ”น Time Complexity: O(n) ๐Ÿ”น Space Complexity: O(1) --- ๐Ÿ”— GitHub: https://github.com/DhruvOzha85 ๐Ÿ”— LeetCode Profile: https://leetcode.com/u/DhruvOzha/ ๐Ÿ”— LinkedIn: https://www.linkedin.com/in/dhruv-ozha-bb378639b/ --- ๐Ÿ“Œ Notes: - Beginner-friendly string problem - Great for practicing character functions - Helps understand validation logic --- ๐Ÿ”ฅ Follow for more daily DSA problem solutions! #leetcode #detectcapital #strings #dsa #codinginterview #cplusplus #programming #algorithms #coding #leetcodeeasy #tech #softwareengineer #placements #codingpractice detect capital, string validation, uppercase lowercase problem, leetcode easy, dsa problems, coding interview questions, c++ dsa, beginner dsa, algorithms, programming, interview prep, coding practice

Download

0 formats

No download links available.

Detect Capital LeetCode | NatokHD