Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions linked-list-cycle/sangyyypark.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Definition for singly-linked list.
* class ListNode {
* int val;
* ListNode next;
* ListNode(int x) {
* val = x;
* next = null;
* }
* }
*/
public class Solution {
public boolean hasCycle(ListNode head) {
Set<ListNode> set = new HashSet();
ListNode current = head;
set.add(current);
while(current != null) {
if(set.contains(current.next)) {
return true;
}
current = current.next;
set.add(current);
}
return false;

}
}

12 changes: 12 additions & 0 deletions sum-of-two-integers/sangyyypark.java
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+,-없이 비트 연산을 사용해서 잘 푸셨네요..!! 👍

Original file line number Diff line number Diff line change
@@ -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;
}
}