Skip to content

Comments

Add Java solution for First Non-Repeated Character in a String#737

Merged
ghostmkg merged 1 commit intoghostmkg:mainfrom
Piyush-Kumar62:first-non-repeated-char
Oct 9, 2025
Merged

Add Java solution for First Non-Repeated Character in a String#737
ghostmkg merged 1 commit intoghostmkg:mainfrom
Piyush-Kumar62:first-non-repeated-char

Conversation

@Piyush-Kumar62
Copy link
Contributor

Problem

Find the first non-repeated character in a string.

Approach

  • Used a LinkedHashMap to store the frequency of each character while maintaining insertion order.
  • Iterated over the map to find the first character with a count of 1.
  • Added detailed comments and explanation in the code.

Time & Space Complexity

  • Time Complexity: O(n)
  • Space Complexity: O(n)

Example Inputs & Outputs

  • Input: "swiss" → Output: "First non-repeated character: w"
  • Input: "hello" → Output: "First non-repeated character: h"

This PR adds a clean, well-explained Java solution ready for DSA repository.

@ghostmkg ghostmkg merged commit 8e04627 into ghostmkg:main Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants