Added solution to leetcode problem 190 in C

This commit is contained in:
SaurusXI 2019-10-04 01:11:00 +05:30
parent 3a21e49ecd
commit e8da4c7714
2 changed files with 11 additions and 0 deletions

View File

@ -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| |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| |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| |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| |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| |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| |215|[Kth Largest Element in an Array](https://leetcode.com/problems/kth-largest-element-in-an-array/) | [C](./src/215.c)|Medium|

10
leetcode/src/190.c Normal file
View File

@ -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;
}