James Michael Hare

...hare-brained ideas from the realm of software development...
posts - 166 , comments - 1431 , trackbacks - 0

My Links

News

Welcome to my blog! I'm a Sr. Software Development Engineer in the Seattle area, who has been performing C++/C#/Java development for over 20 years, but have definitely learned that there is always more to learn!

All thoughts and opinions expressed in my blog and my comments are my own and do not represent the thoughts of my employer.

Blogs I Read

Follow BlkRabbitCoder on Twitter

Tag Cloud

Article Categories

Archives

Post Categories

.NET

CSharp

Little Wonders

Little Wonders

vNext

Little Puzzlers: First Non-Repeating Character

I like to keep my brain sharp by working on programming puzzlers. On off weeks I'm going to start posting programming puzzlers I've collected over the years. Hopefully you'll find them as entertaining as I do.

The Problem

​Given an unbounded sequence of characters, find the value and position of the first non-repeated character.

e.g., in the stream: A,B,C,D,C,B,A,F,A,F the first non-repeated character is D.

For the purposes of this exercise, consider the following interface as the source of the stream:

   1: // C#
   2: public interface ICharStream
   3: {
   4:     bool HasNext { get; }
   5:     char GetNext();
   6: }

Spoiler Alert

Fair Warning: discussion of the problem and potential solutions may be discussed in the comments below. 

Print | posted on Monday, March 9, 2015 9:22 AM | Filed Under [ My Blog C# .NET Little Puzzlers ]

Powered by: