Skip to content

Commit 75fe368

Browse files
committed
add solution for reverse-bits
1 parent 0990e31 commit 75fe368

2 files changed

Lines changed: 104 additions & 0 deletions

File tree

dalestudy.iml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<orderEntry type="sourceFolder" forTests="false" />
6+
<orderEntry type="module-library" exported="">
7+
<library>
8+
<CLASSES />
9+
<JAVADOC />
10+
<SOURCES>
11+
<root url="file://$MODULE_DIR$" />
12+
<root url="file://$MODULE_DIR$/3sum" />
13+
<root url="file://$MODULE_DIR$/alien-dictionary" />
14+
<root url="file://$MODULE_DIR$/best-time-to-buy-and-sell-stock" />
15+
<root url="file://$MODULE_DIR$/binary-tree-level-order-traversal" />
16+
<root url="file://$MODULE_DIR$/binary-tree-maximum-path-sum" />
17+
<root url="file://$MODULE_DIR$/climbing-stairs" />
18+
<root url="file://$MODULE_DIR$/clone-graph" />
19+
<root url="file://$MODULE_DIR$/coin-change" />
20+
<root url="file://$MODULE_DIR$/combination-sum" />
21+
<root url="file://$MODULE_DIR$/construct-binary-tree-from-preorder-and-inorder-traversal" />
22+
<root url="file://$MODULE_DIR$/container-with-most-water" />
23+
<root url="file://$MODULE_DIR$/contains-duplicate" />
24+
<root url="file://$MODULE_DIR$/counting-bits" />
25+
<root url="file://$MODULE_DIR$/course-schedule" />
26+
<root url="file://$MODULE_DIR$/decode-ways" />
27+
<root url="file://$MODULE_DIR$/design-add-and-search-words-data-structure" />
28+
<root url="file://$MODULE_DIR$/encode-and-decode-strings" />
29+
<root url="file://$MODULE_DIR$/find-median-from-data-stream" />
30+
<root url="file://$MODULE_DIR$/find-minimum-in-rotated-sorted-array" />
31+
<root url="file://$MODULE_DIR$/graph-valid-tree" />
32+
<root url="file://$MODULE_DIR$/group-anagrams" />
33+
<root url="file://$MODULE_DIR$/house-robber" />
34+
<root url="file://$MODULE_DIR$/house-robber-ii" />
35+
<root url="file://$MODULE_DIR$/implement-trie-prefix-tree" />
36+
<root url="file://$MODULE_DIR$/insert-interval" />
37+
<root url="file://$MODULE_DIR$/invert-binary-tree" />
38+
<root url="file://$MODULE_DIR$/jump-game" />
39+
<root url="file://$MODULE_DIR$/kth-smallest-element-in-a-bst" />
40+
<root url="file://$MODULE_DIR$/linked-list-cycle" />
41+
<root url="file://$MODULE_DIR$/longest-common-subsequence" />
42+
<root url="file://$MODULE_DIR$/longest-consecutive-sequence" />
43+
<root url="file://$MODULE_DIR$/longest-increasing-subsequence" />
44+
<root url="file://$MODULE_DIR$/longest-palindromic-substring" />
45+
<root url="file://$MODULE_DIR$/longest-repeating-character-replacement" />
46+
<root url="file://$MODULE_DIR$/longest-substring-without-repeating-characters" />
47+
<root url="file://$MODULE_DIR$/lowest-common-ancestor-of-a-binary-search-tree" />
48+
<root url="file://$MODULE_DIR$/maximum-depth-of-binary-tree" />
49+
<root url="file://$MODULE_DIR$/maximum-product-subarray" />
50+
<root url="file://$MODULE_DIR$/maximum-subarray" />
51+
<root url="file://$MODULE_DIR$/meeting-rooms" />
52+
<root url="file://$MODULE_DIR$/meeting-rooms-ii" />
53+
<root url="file://$MODULE_DIR$/merge-intervals" />
54+
<root url="file://$MODULE_DIR$/merge-k-sorted-lists" />
55+
<root url="file://$MODULE_DIR$/merge-two-sorted-lists" />
56+
<root url="file://$MODULE_DIR$/minimum-window-substring" />
57+
<root url="file://$MODULE_DIR$/missing-number" />
58+
<root url="file://$MODULE_DIR$/non-overlapping-intervals" />
59+
<root url="file://$MODULE_DIR$/number-of-1-bits" />
60+
<root url="file://$MODULE_DIR$/number-of-connected-components-in-an-undirected-graph" />
61+
<root url="file://$MODULE_DIR$/number-of-islands" />
62+
<root url="file://$MODULE_DIR$/pacific-atlantic-water-flow" />
63+
<root url="file://$MODULE_DIR$/palindromic-substrings" />
64+
<root url="file://$MODULE_DIR$/product-of-array-except-self" />
65+
<root url="file://$MODULE_DIR$/remove-nth-node-from-end-of-list" />
66+
<root url="file://$MODULE_DIR$/reorder-list" />
67+
<root url="file://$MODULE_DIR$/reverse-bits" />
68+
<root url="file://$MODULE_DIR$/reverse-linked-list" />
69+
<root url="file://$MODULE_DIR$/rotate-image" />
70+
<root url="file://$MODULE_DIR$/same-tree" />
71+
<root url="file://$MODULE_DIR$/search-in-rotated-sorted-array" />
72+
<root url="file://$MODULE_DIR$/serialize-and-deserialize-binary-tree" />
73+
<root url="file://$MODULE_DIR$/set-matrix-zeroes" />
74+
<root url="file://$MODULE_DIR$/spiral-matrix" />
75+
<root url="file://$MODULE_DIR$/subtree-of-another-tree" />
76+
<root url="file://$MODULE_DIR$/sum-of-two-integers" />
77+
<root url="file://$MODULE_DIR$/top-k-frequent-elements" />
78+
<root url="file://$MODULE_DIR$/two-sum" />
79+
<root url="file://$MODULE_DIR$/unique-paths" />
80+
<root url="file://$MODULE_DIR$/valid-anagram" />
81+
<root url="file://$MODULE_DIR$/valid-palindrome" />
82+
<root url="file://$MODULE_DIR$/valid-parentheses" />
83+
<root url="file://$MODULE_DIR$/validate-binary-search-tree" />
84+
<root url="file://$MODULE_DIR$/word-break" />
85+
<root url="file://$MODULE_DIR$/word-search" />
86+
<root url="file://$MODULE_DIR$/word-search-ii" />
87+
</SOURCES>
88+
</library>
89+
</orderEntry>
90+
</component>
91+
</module>

reverse-bits/Hyeri1ee.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public int reverseBits(int n) {
3+
int result =0;
4+
for(int i=0; i< 32;i++){
5+
result <<= 1;
6+
result |= (n & 1);
7+
n >>= 1;
8+
}
9+
10+
return result;
11+
}
12+
}
13+

0 commit comments

Comments
 (0)