diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 00000000..ab1f4164
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,10 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Ignored default folder with query files
+/queries/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/.idea/Design-1.iml b/.idea/Design-1.iml
new file mode 100644
index 00000000..d6ebd480
--- /dev/null
+++ b/.idea/Design-1.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000..2bfdeda2
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 00000000..cc065d00
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..35eb1ddf
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MinStack.java b/MinStack.java
new file mode 100644
index 00000000..56f19b8f
--- /dev/null
+++ b/MinStack.java
@@ -0,0 +1,82 @@
+// Time Complexity : O(1) for push, pop, top, and getMin
+// Space Complexity : O(n) as we store all elements in the stack
+// Did this code successfully run on Leetcode : Yes
+// Any problem you faced while coding this : Faced minor difficulty in translating tuple-based approach to Java, I had done in c# before.
+// Your code here along with comments explaining your approach
+// As a pair we can store the value and the minimum value at that point in the stack.
+// So when we push a new value, we can compare it with the current minimum and store the new minimum if necessary.
+// This way, we can retrieve the minimum value in O(1) time by looking at the top of the stack.
+import java.util.Stack;
+class MinStack {
+ Stack st;
+ int min;
+
+ public MinStack() {
+ this.st = new Stack<>();
+ this.min = Integer.MAX_VALUE;
+ }
+
+ public void push(int val) {
+ if(min >= val){
+ st.push(min);
+ min = val;
+ }
+ st.push(val);
+ }
+
+ public void pop() {
+ if(min == st.pop()){
+ min = st.pop();
+ }
+ }
+
+ public int top() {
+ return st.peek();
+ }
+
+ public int getMin() {
+ return min;
+ }
+}
+
+
+
+/**
+ * Your MinStack object will be instantiated and called as such:
+ * MinStack obj = new MinStack();
+ * obj.push(val);
+ * obj.pop();
+ * int param_3 = obj.top();
+ * int param_4 = obj.getMin();
+ */
+
+/**
+ * Your MinStack object will be instantiated and called as such:
+ * MinStack obj = new MinStack();
+ * obj.push(val);
+ * obj.pop();
+ * int param_3 = obj.top();
+ * int param_4 = obj.getMin();
+ */
+class Main {
+ public static void main(String args[])
+ {
+ MinStack obj = new MinStack();
+ obj.push(-2);
+ obj.push(0);
+ obj.push(-3);
+ System.out.println(obj.getMin()); // return -3
+ obj.pop();
+ System.out.println(obj.top()); // return 0
+ System.out.println(obj.getMin()); // return -2
+ MyHashSet obj1 = new MyHashSet();
+ obj1.add(1);
+ obj1.add(2);
+ System.out.println(obj1.contains(1)); // returns true
+ System.out.println(obj1.contains(3)); // returns false (not found)
+ obj1.add(2);
+ System.out.println(obj1.contains(2)); // returns true
+ obj1.remove(2);
+ System.out.println(obj1.contains(2)); // returns false (already removed)
+ }
+}
diff --git a/MyHashSet.java b/MyHashSet.java
new file mode 100644
index 00000000..17109e5c
--- /dev/null
+++ b/MyHashSet.java
@@ -0,0 +1,65 @@
+class MyHashSet {
+ Node[] storage;
+ int buckets;
+
+ class Node {
+ int key;
+ Node next;
+
+ public Node(int key) {
+ this.key = key;
+ }
+ }
+
+ public MyHashSet() {
+ this.buckets = 1000;
+ this.storage = new Node[buckets];
+ }
+
+ private int getHash(int key){
+ return key % buckets;
+ }
+
+ private Node getPrev(Node head, int key){
+ Node prev = null;
+ Node curr = head;
+ while(curr != null && curr.key != key){
+ prev = curr;
+ curr = curr.next;
+ }
+ return prev;
+ }
+
+
+ public void add(int key) {
+ int index = getHash(key);
+ if(storage[index] == null){
+ storage[index] = new Node(-1);
+ storage[index].next = new Node(key);
+ return;
+ }
+
+ Node prev = getPrev(storage[index], key);
+ if(prev.next == null){
+ prev.next = new Node(key);
+ }
+ }
+
+ public void remove(int key) {
+ int index = getHash(key);
+ if(storage[index] == null) return;
+ Node prev = getPrev(storage[index], key);
+ if(prev.next == null) return;
+ Node curr = prev.next;
+ prev.next = curr.next;
+ curr.next = null;
+ }
+
+ public boolean contains(int key) {
+ int index = getHash(key);
+ if(storage[index] == null) return false;
+ Node prev = getPrev(storage[index], key);
+ if(prev.next == null) return false;
+ return true;
+ }
+}
diff --git a/Sample.java b/Sample.java
index 1739a9cb..57c7731e 100644
--- a/Sample.java
+++ b/Sample.java
@@ -5,3 +5,64 @@
// Your code here along with comments explaining your approach
+import java.util.LinkedList;
+
+
+
+class MyHashSet {
+ class Entry{
+ public int key;
+ public Entry(int key){
+ this.key = key;
+ }
+ }
+ LinkedList[] set;
+ public static int size = 769;
+ public MyHashSet() {
+ set = new LinkedList[size];
+ }
+
+ public void add(int key) {
+ int bucket = (key % size);
+ if (set[bucket] == null) set[bucket] = new LinkedList<>();
+ for (Entry e : set[bucket]) {
+ if (e.key == key) return;
+ }
+ set[bucket].addLast(new Entry(key));
+ }
+
+ public void remove(int key) {
+ int bucket = (key % size);
+ if (set[bucket] != null) {
+ Entry toRemove=null;
+ for (Entry e : set[bucket]) {
+ if (e.key == key)
+ {
+ toRemove=e;
+ break;
+ }
+ }
+ if(toRemove!=null) set[bucket].remove(toRemove);
+ }
+
+
+ }
+
+ public boolean contains(int key) {
+ int bucket = (key % size);
+ if (set[bucket] != null) {
+ for (Entry e : set[bucket]) {
+ if (e.key == key) return true;
+ }
+ }
+ return false;
+ }
+}
+
+/**
+ * Your MyHashSet object will be instantiated and called as such:
+ * MyHashSet obj = new MyHashSet();
+ * obj.add(key);
+ * obj.remove(key);
+ * boolean param_3 = obj.contains(key);
+ */
\ No newline at end of file