We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents f7ff8fb + d6baed5 commit 0556fe3Copy full SHA for 0556fe3
2 files changed
linked-list-cycle/sangyyypark.java
@@ -0,0 +1,28 @@
1
+/**
2
+ * Definition for singly-linked list.
3
+ * class ListNode {
4
+ * int val;
5
+ * ListNode next;
6
+ * ListNode(int x) {
7
+ * val = x;
8
+ * next = null;
9
+ * }
10
11
+ */
12
+public class Solution {
13
+ public boolean hasCycle(ListNode head) {
14
+ Set<ListNode> set = new HashSet();
15
+ ListNode current = head;
16
+ set.add(current);
17
+ while(current != null) {
18
+ if(set.contains(current.next)) {
19
+ return true;
20
+ }
21
+ current = current.next;
22
23
24
+ return false;
25
+
26
27
+}
28
sum-of-two-integers/sangyyypark.java
@@ -0,0 +1,12 @@
+class Solution {
+ public int getSum(int a, int b) {
+ while(b != 0) {
+ int sum = a ^ b;
+ int carry = (a & b) << 1;
+ a = sum;
+ b = carry;
+ return a;
0 commit comments