Geeksforgeeks

Error

×

Leaderboard

Showing:

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

@Ibrahim Nash | 6420 |

@blackshadows | 6376 |

@mb1973 | 5594 |

@Quandray | 5231 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4510 |

@sanjay05 | 3762 |

@kirtidee18 | 3673 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3412 |

Complete Leaderboard | |

Handle | Score |

@codersgroup18 | 783 |

@Manikanta punnam | 605 |

@sriramgoparaju99 | 594 |

@rdakka | 538 |

@praveenbgp6 | 529 |

@prankursharma31 | 518 |

@yashkaril4 | 517 |

@purohitmn02 | 467 |

@sonamnigam1999 | 443 |

@sonamkumari63928 | 441 |

@shubhamstudent5 | 433 |

Complete Leaderboard |

Given a number N, change all bits at even positions to 0.

**Example 1:**

**Input**: N = 30
**Output:** 10
**Explanation**: Binary representation of
**1**1**1**1**0**. Bits at Even positions are
highlighted. After making all of them
0, we get **0**1**0**1**0. **Hence the answer is 10.

**Example 2:**

**Input: **N = 10
**Output: **10
**Explanation**: Binary representation of
1**0**1**0**. Bits at Even positions are
highlighted. After making all of them
0, we get 1**0**1**0.** Hence the answer is 10.

**Your Task: **

You dont need to read input or print anything. Complete the function **convertEvenBitToZero() **which takes n as input parameter and returns the value of N after changing bits at even positions.

**Expected Time Complexity:** O(1)

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

**Constraints:**

1<= N <=(32-bit number)

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
Change all even bits in a number to 0

...