One of the tags for Integers have friends problem is binary search but I am not able to figure out how to apply binary search without using segment tree and sparse table.(since i'm a beginner i actually don't know segment tree and sparse table). I want to do it using only binary search if it's possible. My approach: For a value X check if it's possible that max size of friend group is less than or equal to X, if i'm able to do this in O(n) then it's solved but i don't know how to do this in O(n). Am i missing something is there any other way to do it using binary search?