My solution is in Python. I didn't pass all of the Test Cases (although I would have passed the test cases on my local machine, on the server in which it was marked, it exceeded the timeout period. My algorithm is therefore too inefficient. If anybody can make any suggestions).
Spoiler:
My initial thought is to write a custom sort function, and then store the location in the list for all possible values N (in which case I won't ever have to call upon the bisect_right method). Calling sort and then frequently calling bisect_right seems quite inefficient (though I suspect I would have passed with this algorithm in a fast, compiled language like C).
Results 1 to 1 of 1
-
01-15-2012 02:55 AM #1
- Join Date
- Oct 2009
- Posts
- 1,017
- Rep
- 255
Interviewstreet CS 2 - Picking Cards
Last edited by Artificial; 01-15-2012 at 02:59 AM.
Tags for this Thread



Reply With Quote

Bookmarks