algorithm establish array contains n...n+m?
i saw doubt reddit, there certain solutions presented, i guess ideal doubt ask here. thread talk questions:
write slight takes an int array distance m, advantage (true/false) array consists numbers n...n+m-1, numbers operation wholly numbers range. array guaranteed sorted. (for instance, {2,3,4} relapse true. {1,3,1} relapse false, {1,2,4} relapse false.
the problem i interviewer kept seeking me optimize (faster o(n), reduction memory, etc), indicate where claimed pass array controlling consistent volume memory. never figured out.
along your solutions greatfully infer assume array contains unparalleled items. also infer your fortitude assumes method starts during 1. (i've run-down doubt rather grant cases where goes 2, 3, 4...)
edit: i am opinion there does exist linear consistent space algorithm handles duplicates. anyone establish this?
the register problem boils down contrast array contains duplicates o(n) time, o(1) space. finished simply exam initial there duplicates run algorithms posted. exam dupes o(n) o(1) space?
Comments
Post a Comment