E05: isUnique (Cracking the Coding Interview, Problem 1)

Cracking the Coding Interview (CTCI) is widely regarded as a preeminent resource to prepare for modern software development position interviews at leading high tech companies.

The goal of this experience is to continue to get familiar with writing very simple Javascript code using JSFiddle, and to get you acquainted with the “Workout of the Day” (WOD) pedagogical technique used in this course.

To do this, you will solve the very first problem in CTCI, called “isUnique”:

1.1. Is Unique: Implement an algorithm to determine if a string has all unique characters.

For example:

console.log(isUnique('abcde'));  // prints true
console.log(isUnique('abcdea')); // prints false

Prelude

You should probably have finished the previous practice WOD.

Review the first few sections of the AirBnB Javascript Style Guide. For example, be sure to use let and const, not var.

Next, login to JSFiddle (creating an account if you haven’t already).

Check the settings pane to make sure the console window is displayed in the editor, and the layout is to your liking (I prefer “Tabs (rows)”).

To make the result window dark for your new JSFiddle, add the following to the CSS pane:

body { background-color: #1f2227; }

You may also want to reduce the height of the result window, so that more space is provided for the Javascript window.

Demonstration

Once you’ve finished trying to do it, watch me do it:

Submission Instructions

By the time and date indicated on the Schedule page, submit this assignment via Laulima.

Your submission should contain:

You will receive full credit for this practice WOD as long as you have attempted it at least once and submitted your work on Laulima with all required data before the due date. Your code does not have to run perfectly for you to receive full credit.