Skip to content

Instantly share code, notes, and snippets.

@arunsivasankaran
Created January 15, 2015 21:57
Show Gist options
  • Save arunsivasankaran/eb8168cc67f6794471bb to your computer and use it in GitHub Desktop.
Save arunsivasankaran/eb8168cc67f6794471bb to your computer and use it in GitHub Desktop.
Hired.com Questions
1) check whether two words are anagrams
2) check whether an expressions opening and closing braces match
3) you have an array of numbers. you want this array of numbers to be in ascending order. consider a number d. you can add/subtract any number in your array by any number <= d. what is the smallest d you could use to make the array ascending? (my hint: think worst case)
4) you have an array of numbers. find the subarray of a given length that has the biggest max-min difference. eg. you have an array of size 10, and you want to find the subarray of size 3 that has the biggest max-min difference.
5) something along these lines. you have an array. you can break the array into various pairs of non-overlapping subarrays. consider one of these pairs. each subarray in the pair has a max value. the pair can have a property that holds the difference between each sub's max. lets call that property subDiff. find the pair with the biggest subDiff. (I ran out of time, but I could have done it!)
I had 90 minutes to answer the first two and choose one of the other 3 to answer. I actually didn't realize the instructions until the end and thought I had to answer all 5 in 90 minutes lol.
These all had efficiency requirements too. I did 4) in O(n^2) time but the tests weren't all passing so I guess there's a more efficient way to do it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment