Unique Number

OVERVIEW

We are going to write an algorithm that will detect the String to make sure that it is unique in the sense of not containing duplicate alphabet. For example, the word Hello is not unique as it contains 2 l’s.

With the code below, we simply return either true or false depending if the value is unique or not. The code loops through the input appending each character into usedLetters  and with the if statement to check if there are duplicates. If there is duplicates, it will return false.

The result is as follow

 

  • Article By :
    Founder of DaddyCoding. Studied Computer Science, Information System and Information Technology at BYU-Hawaii. Currently spending most of my time researching and learning on helping to expose making iOS apps.

Random Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*