Error
|
|
---|---|
@Ibrahim Nash | 5761 |
@blackshadows | 5701 |
@akhayrutdinov | 5111 |
@mb1973 | 4989 |
@Quandray | 4944 |
@saiujwal13083 | 4506 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3516 |
@sushant_a | 3459 |
@verma_ji | 3341 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@aroranayan999 | 938 |
@bt8816103042 | 739 |
@SHOAIBVIJAPURE | 428 |
@codeantik | 412 |
@SherlockHolmes3 | 407 |
@neverevergiveup | 348 |
@mahlawatep | 347 |
@shalinibhataniya1097 | 343 |
@murarry3625 | 333 |
@saiujwal13083 | 326 |
@rohitanand | 314 |
Complete Leaderboard |
Given a binary representation in the form of string(S) of a number n, the task is to find a binary representation of n+1.
Example 1:
Input: S = "10"
Output: 11
Explanation: "10" is the binary
representation of 2 and binary
representation of 3 is "11"
Example 2:
Input: S = "111"
Output: 1000
Explanation: "111" is the binary
representation of 7 and binary
representation of 8 is "1000"
Your Task:
You don't need to read input or print anything. Complete the function binaryNextNumber()which takes S as input parameter and returns the string.
Expected Time Complexity:O(N)
Expected Auxiliary Space: O(N) to store resultant string
Constraints:
1 <= N <= 104
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes