Showing:
Handle Score
@Ibrahim Nash 5761
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4944
@saiujwal13083 4506
@sanjay05 3762
@marius_valentin_dragoi 3516
@sushant_a 3459
@verma_ji 3341
@KshamaGupta 3318
Binary representation of next number
Basic Accuracy: 22.51% Submissions: 40 Points: 1

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"

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