---
title: "Comment by yetanothertroll on \"Javascript: Use a Hash Map to solve \"First Non-Repeating Character\" in O(n) time\" | Hashnode"
description: "Hey, you&#39;re back! Well, for this I&#39;d use a simple two column array BASIC code at https://forums.craigslist.org/?ID=326981539 I neglected to put a guard"
url: "https://hashnode.com/posts/javascript-use-a-hash-map-to-solve-first-non-repeating-character-in-on-time/6478e74ea9c3b8fbbc775bbe/comment/647a27331c128bf71962a1b2"
---

[Discussion](https://hashnode.com/posts/javascript-use-a-hash-map-to-solve-first-non-repeating-character-in-on-time/6478e74ea9c3b8fbbc775bbe)

Comment [Javascript: Use a Hash Map to solve "First Non-Repeating Character" in O(n) time](https://hashnode.com/posts/javascript-use-a-hash-map-to-solve-first-non-repeating-character-in-on-time/6478e74ea9c3b8fbbc775bbe)

[yetanothertroll](https://hashnode.com/@yetanothertroll)

[Jun 2, 2023](https://hashnode.com/posts/javascript-use-a-hash-map-to-solve-first-non-repeating-character-in-on-time/6478e74ea9c3b8fbbc775bbe/comment/647a27331c128bf71962a1b2)

Hey, you're back! Well, for this I'd use a simple two column array

BASIC code at [forums.craigslist.org](https://forums.craigslist.org/?ID=326981539)

I neglected to put a guard around that first For loop in case the string was empty, oops

[Austin](https://hashnode.com/@austn)

[Jun 2, 2023](https://hashnode.com/posts/javascript-use-a-hash-map-to-solve-first-non-repeating-character-in-on-time/6478e74ea9c3b8fbbc775bbe/comment/647a27331c128bf71962a1b2#reply-647a2c49cc9d6bf749df536e)

Glad to be back :)

I never would have thought of using ASCII math, that's a neat tactic. This would be another O(n) solution right?

I wonder how long it'll be until I post one of these that you couldn't solve in BASIC, you're quick!

[yetanothertroll](https://hashnode.com/@yetanothertroll)

[Jun 2, 2023](https://hashnode.com/posts/javascript-use-a-hash-map-to-solve-first-non-repeating-character-in-on-time/6478e74ea9c3b8fbbc775bbe/comment/647a27331c128bf71962a1b2#reply-647a43631c128bf71962a55e)

[Austin](https://hashnode.com/@austn) It's O(n) since it's one pass through the string and then one pass through the array whose size is constant no matter how big the string gets.

Bring it on! If I can't quickly solve it in BASIC, I probably could in 1983 8-bit Atari LOGO

Still more edits lol — If you're looking for some really crazy challenges, try some Knuth

[yetanothertroll](https://hashnode.com/@yetanothertroll)

[Jan 19, 2025](https://hashnode.com/posts/javascript-use-a-hash-map-to-solve-first-non-repeating-character-in-on-time/6478e74ea9c3b8fbbc775bbe/comment/647a27331c128bf71962a1b2#reply-678d8a243076f504bc0f0319)

[Austin](https://hashnode.com/@austn) Hey, you still alive? Is this an actual leetcode problem? If so, I can't find it. I'm mainly tackling the hard problems in C (the closest thing to BASIC they have lol) but I figured I'd convert the BASIC solutions I posted back in 2023 to C and actually submit them

EDIT: Is it 387. First Unique Character in a String? Looks like it
