File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /*
2+ * ์๊ฐ ๋ณต์ก๋: O(n)
3+ * ๊ณต๊ฐ ๋ณต์ก๋: O(n)
4+ */
5+ public class Solution {
6+ public boolean hasCycle (ListNode head ) {
7+ Set <ListNode > visited = new HashSet <>();
8+ while (head != null ) {
9+ if (visited .contains (head )) {
10+ return true ;
11+ }
12+ visited .add (head );
13+ head = head .next ;
14+ }
15+ return false ;
16+ }
17+ }
Original file line number Diff line number Diff line change 33 * ๊ณต๊ฐ ๋ณต์ก๋: O(1)
44 */
55class Solution {
6+ public int reverseBits (int n ) {
7+ int result = 0 ;
8+
9+ for (int i = 0 ; i < 32 ; i ++) {
10+ result = (result << 1 ) | (n & 1 );
11+ n >>= 1 ;
12+ }
13+ return result ;
14+ }
15+ }
16+
17+ /*
18+ * ์๊ฐ ๋ณต์ก๋: O(1)
19+ * ๊ณต๊ฐ ๋ณต์ก๋: O(32)
20+ *
21+ * ํด๋น ์ฝ๋๋ก๋ ๋์ํ์ง๋ง ๋ฌธ์์ด ๋ณํ -> ๋ค์ง๊ธฐ -> ๋ค์ ๋ฌธ์์ด ํ์ฑ์ ๊ณผ์ ์ ๊ฑฐ์น์ง ์๊ณ
22+ * ๋นํธ๋ฅผ ์กฐ์ํ๋ ๊ฒ์ด ๋ฌธ์ ์ ์๋์ ๋ ๋ถํฉํจ.
23+ *
24+ class Solution {
625
726 public static String toBinaryString(int value) {
827 String str = Integer.toBinaryString(value);
@@ -20,3 +39,4 @@ public int reverseBits(int n) {
2039 return result;
2140 }
2241}
42+ */
You canโt perform that action at this time.
0 commit comments