Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6420 |

@blackshadows | 6376 |

@mb1973 | 5604 |

@Quandray | 5231 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4510 |

@sanjay05 | 3762 |

@kirtidee18 | 3673 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3413 |

Complete Leaderboard | |

Handle | Score |

@codersgroup18 | 799 |

@sriramgoparaju99 | 737 |

@Manikanta punnam | 629 |

@rdakka | 606 |

@prankursharma31 | 597 |

@praveenbgp6 | 546 |

@sanskar94511 | 531 |

@purohitmn02 | 525 |

@yashkaril4 | 517 |

@abhikarshgupta | 474 |

@rohitgarg2825 | 464 |

Complete Leaderboard |

Given a binary number, Find, if given binary number is a multiple of 3. The given number can be big upto 2^10000. It is recommended to finish the task using one traversal of input binary string.

**Example 1:**

**Input**: S = "011"
**Output:** 1
**Explanation**: "011" decimal equivalent
is 3, which is divisible by 3.

â€‹**Example 2:**

**Input**: S = "100"
**Output:** 0
**Explanation**: "100" decimal equivalent
is 4, which is not divisible by 3.

**Your Task: **

You don't need to read input or print anything. Your task is to complete the function **isDivisible()** which takes the string **s **as inputs and returns 1 if the given number is divisible by 3 otherwise 0.

**Expected Time Complexity:** O(|S|)

**Expected Auxiliary Space:** O(1)

**Constraints:**

1 ≤ |S| ≤ 10^{5}

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Is Binary Number Multiple of 3

...