Maximum binary numbers(Hackerearth problem)

Can anyone help me to solve this problem :frowning:

Problem Link : Maximum binary numbers | Practice Problems

What I want to understand :-

  • How can we know the maximum possible value of a binary string within time limits like O(n) or O(nlogn) (n is length of string)?
  • Is there some standard approach for this problem ?