Solving LeetCode Problem 387: First Unique Character in a String

• Solving LeetCode Problem | Day 13 • Problem: First Unique Character in a String | LeetCode 387 • Approach: Instead of checking every character multiple times (O(n²)), I used a frequency array. Step 1: Count occurrences of each character Step 2: Traverse again to find the first character with frequency = 1 This keeps the logic simple and avoids unnecessary comparisons. • Time Complexity: O(n) • Space Complexity: O(1) • What I Learned: Trying to force everything into one loop can make the solution messy. Breaking the problem into two clean passes often leads to better clarity and efficiency. #leetcode #dsa #java #programming #coding #algorithms #problemSolving #100daysofcode

  • text

To view or add a comment, sign in

Explore content categories