Skip to content

Some algorithm examples (and my solutions) that you would have to deal with in an interview process.

Notifications You must be signed in to change notification settings

alfonsomartinde/algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Algorithms

Some algorithms I've had to deal with, in some interview process.

Some examples

"Given a one-directional list of movie titles in order of how long ago you watched them (there may be duplicates), find the least-recently watched singleton movie title."

"Given a binary tree, design an algorithm that does a level order traversal of the tree, where each level is printed out in the reverse order as the previous level."

"you're a guard of a prison, you want to keep an eye on the most dangerous prisoner. Each prisoner has a danger rank of his own and a group of friends (who also have danger ranks). You'll need to go through the prison and find out the prisoner who has the highest danger rank (his own + all his friends)"

Solved algorithms:

"Given a string, how do we check if any anagram of it can be a palindrome? For example let us consider the string 'AAC'. An anagram of it is 'ACA' which is a palindrome. We have to write a method which takes a string and outputs true if we can form a palindrome from any anagram of the given string. Otherwise outputs false."

"Given an array of strings, return the first one which appears only once in the array."

"If you have a string like 'I am the good boy'. How can you generate 'I ma eht doog yob'? Please note that the words are in place but reverse."

"Given an array of numbers arr, find the first index at which the sums before and after that index are equal. If there're no equilibrium index, then return -1. For example: given [9,12,3,4,6,1,3,7], the first equilibrium index is 2, because the sum of left side [9,12], is the same that the sum of the right part [4,6,1,3,7]: 9 + 12 === 4 + 6 + 1 + 3 + 7"

About

Some algorithm examples (and my solutions) that you would have to deal with in an interview process.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published