2 votes 2 votes Algorithms algorithms time-complexity made-easy-test-series + – rahul sharma 5 asked Oct 18, 2017 retagged Jul 17, 2022 by makhdoom ghaya rahul sharma 5 899 views answer comment Share Follow See all 12 Comments See all 12 12 Comments reply Show 9 previous comments Tesla! commented Oct 21, 2017 reply Follow Share http://www.geeksforgeeks.org/nuts-bolts-problem-lock-key-problem/ best solution possible 0 votes 0 votes rahul sharma 5 commented Oct 21, 2017 reply Follow Share But worst case should be 0(n^2)? @joshi_nitish,question does not says average case here? 0 votes 0 votes joshi_nitish commented Oct 21, 2017 reply Follow Share yes it should be O(n^2) in worst case.. 1 votes 1 votes Please log in or register to add a comment.
0 votes 0 votes This is a classical algo problem How intruiging this prblem is makes you fall in love with algorithms It may seem at a glance that it is nlogn but the truth is it isnt It is O(n^2) https://courses.engr.illinois.edu/cs473/sp2017/notes/02-nutsbolts.pdf shashankrustagi answered Dec 31, 2020 shashankrustagi comment Share Follow See all 0 reply Please log in or register to add a comment.