First Unique Character in a String
In this video, I solved the LeetCode problem "First Unique Character in a String" using a Hash Map. Problem: Given a string s, find the first non-repeating character and return its index. If it does not exist, return -1. Approach: We use a hash map to store the frequency of each character. Steps: 1. Traverse the string and count occurrences of every character 2. Traverse the string again 3. Return the index of the first character with frequency 1 This helps us efficiently find the first unique character. Time Complexity: O(n) Space Complexity: O(1) GitHub Link: https://github.com/Kumar-Aditya-DEV/Leetcode-Questions LeetCode Profile: https://leetcode.com/u/Aditya-Kumar-DEVP/ LinkedIn: https://www.linkedin.com/in/aditya-kumar-060ba6376/ Notes: * Uses Hash Map for frequency counting * Important string manipulation problem * Two-pass efficient solution * Frequently asked in coding interviews Language: C++ If this helped you, Like, Share and Subscribe for more coding content. #leetcode #cpp #dsa #coding #strings #hashmap
Download
0 formatsNo download links available.