# Taken from Cracking the Coding Interview 5th Edition
# Must Know Problems

# 1.1 Implement an algorithm to determine if a string has all unique characters 
# What if you can not use additional data structures?

def uniqueChars(str):
  seen = ''
  for let in str:
    if seen.find(let) != -1:
      return False
    seen+=let
  return True

# 1.2 Write code to reverse a C-Style String 
# (C-String means that “abcd” is represented as five characters, including the null character )

string = 'dsafasdf'
reverse = string[::-1]

# 1.6 Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, 
# write a method to rotate the image by 90 degrees Can you do this in place?

# 2.6 Given a circular linked list, implement an algorithm which returns the node at the beginning of the loop.
# DEFINITION
# Circular linked list: A (corrupt) linked list in which a node's next pointer points
# to an earlier node, so as to make a loop in the linked list.
# EXAMPLE
# Input: A ->B->C->D->E- > C [the same C as earlier]
# Output: C

# 3.1 Describe how you could use a single array to implement three stacks

# 3.2 How would you design a stack which, in addition to push and pop, 
# also has a function min which returns the minimum element? 
# Push, pop and min should all operate in O(1) time

# 3.6 Write a program to sort a stack in ascending order 
# You should not make any assumptions about how the stack is implemented 
# The following are the only functions that should be used to write this program: push | pop | peek | isEmpty

# 4.2 Given a directed graph, design an algorithm to find out whether there is a route between two nodes.

# 16.2 How would you measure the time spent in a context switch?