diff --git a/leetcode/README.md b/leetcode/README.md index 6388c697..ee8da066 100644 --- a/leetcode/README.md +++ b/leetcode/README.md @@ -31,6 +31,7 @@ LeetCode |160|[Intersection of Two Linked Lists](https://leetcode.com/problems/intersection-of-two-linked-lists/) | [C](./src/160.c)|Easy| |169|[Majority Element](https://leetcode.com/problems/majority-element/) | [C](./src/169.c)|Easy| |173|[Binary Search Tree Iterator](https://leetcode.com/problems/binary-search-tree-iterator/) | [C](./src/173.c)|Medium| +|190|[Reverse Bits](https://leetcode.com/problems/reverse-bits/) | [C](./src/190.c)|Easy| |203|[Remove Linked List Elements](https://leetcode.com/problems/remove-linked-list-elements/) | [C](./src/203.c)|Easy| |206|[Reverse Linked List](https://leetcode.com/problems/reverse-linked-list/) | [C](./src/206.c)|Easy| |215|[Kth Largest Element in an Array](https://leetcode.com/problems/kth-largest-element-in-an-array/) | [C](./src/215.c)|Medium| diff --git a/leetcode/src/190.c b/leetcode/src/190.c new file mode 100644 index 00000000..7d412d58 --- /dev/null +++ b/leetcode/src/190.c @@ -0,0 +1,10 @@ +uint32_t reverseBits(uint32_t n) { + uint TotalBits = 32; + uint32_t reverse_int = 0; + uint i; + for(i = 0; i < TotalBits; i++) { + if((n & (UINT32_C(1) << i))) + reverse_int = reverse_int | (UINT32_C(1) << (TotalBits - 1 - i)); + } + return reverse_int; +} \ No newline at end of file