Sharpen your coding skills!

This article is part of my personal habit of writing coding problems in with my most relevant language to stay sharp on my programming and problem solving skills. The First Non-Repeating Character question is a well-known beginner computer science question. Here we will understand the problem, write table-driven tests and develop two solutions using Go.

Let’s code!

Understand The Problem

While the title is fairly self-descriptive, it’s always best to understand a coding problem by first walking through some examples. In our case, the First Non-Repeating Character problem is defined by an input of a single string of English characters and an output of the index of the string’s first non-repeating character. If there are no non-repeating characters, then the function should return -1.

Here are a few examples:

----- Example 1 -----
Input:  abbcddeff
Output: 0
----- Example 2 -----
Input:  abbNadNe
Output: 4
----- Example 3 -----
Input:  ddd
Output: -1

You should always try working out these examples yourself, especially in a coding interview, to gain an initial grasp of the problem. This question can be understood with just a few examples, so now let’s move onto the tests.

#tutorial #golang #technology #programming

Coding Problem: First Non-Repeating Character in Go
2.30 GEEK