Skip to content

MarioMartReq/coding-interview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Coding interview practice exercises.

Hi, this is a repo to keep track of all the coding exercises I have done. I'll try to keep them with a description, solution explanation and complexity analysis.

Categories and problem list.

Arrays.

  • Array rotation: Rotate an array a number of times to the right. Done in place and with complexity O(1).
  • Remove duplicates: Remove the duplicates inside of a sorted list. This contains the generic one-line used to remove duplicates.
  • Matrix rotation: Rotate a matrix 90º. The solution inside is done in a single line. Reverse + Transposition = Rotation.
  • Two sum target: Find two elements inside of an array that by adding them you obtain the target number.
  • Zeroes to the back: Move all zeroes in a list to the back without altering the order of the rest of the elements.

Strings.

Algorithms.

  • Max profit: Find maximum profit obtainable by holding and selling from a period of stock prices.
  • Tree height: Find the height of a binary tree. This example does this recursively and implements a Tree class.
  • Triangles: Find triplets that form a triangle, defined by a set of rules.

Math.

  • FizzBuzz: Given a number, write a list of number up to that given numb and if it's divisible between 3 or/and 5 you write "Fuzz" or/and "Bizz" respectively.
  • Roman to integer: Program to transform from roman to integer. Uses an inline iterator and a dictionary.
  • Is N a power of M?: Given M and N, say if N is a power of M. Done without loops.
  • Primes til M: Given a number M, list all the prime numbers smaller than that number. Implemented with the Sieve of Eratosthenes.

This is the place where I come to cry after I forget how to Python after some months doing just yamls