Skip to content

Instantly share code, notes, and snippets.

@shufengh
Last active December 26, 2015 02:29
Show Gist options
  • Save shufengh/7079447 to your computer and use it in GitHub Desktop.
Save shufengh/7079447 to your computer and use it in GitHub Desktop.
I saw these questions in other places and think it may be worth a try.
Question 1:
Given a finite set of unique numbers, find all the runs in the set.
Runs are 1 or more consecutive numbers.
That is, given {1,59,12,43,4,58,5,13,46,3,6},
the output should be: {1}, {3,4,5,6}, {12,13}, {43}, {46},{58,59}.
Note that the size of the set may be very large.
If you think it's too easy, you can take a look at the discussion here:
http://ayende.com/blog/163394/new-interview-question
Or you may want to think a little bit before clicking it.
Question 2:
You're given a modified text editor and there are only three operations
you can take: select all, copy and paste. Initially there's only one letter
in the editable area. If you can take only N operations, compute the largest
number of letters you can get finally.
The input is N and output should be the largest number of letters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment