LeetCode Reverse Bits, leetcodereverse

Source: Internet
Author: User

LeetCode Reverse Bits, leetcodereverse

Reverse Bits Total Accepted: 8148 Total Submissions: 29905 My Submissions Question Solution
Reverse bits of a given 32 bits unsigned integer.

For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 00111001011110000010100101000000 ).

Question:
The binary number is reversed. In another example, 1011 is reversed and 11010000000000000000000000000000 is displayed. The preceding 0 is included at the end.

Class Solution {public: uint32_t reverseBits (uint32_t n) {int t = 0; int c = 0; while (c <32) {t <= 1; t | = (n & 1); n >>= 1; c ++;} return t ;}};

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.