Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
kunal-kushwaha authored Jan 11, 2022
2 parents 8cda733 + 18f242d commit b058125
Show file tree
Hide file tree
Showing 21 changed files with 536 additions and 6 deletions.
13 changes: 7 additions & 6 deletions SYLLABUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
- [Introduction](https://youtu.be/4EP8YzcN0hQ)
- [How it works](https://youtu.be/4EP8YzcN0hQ?t=93)
- [Setup Installation](https://youtu.be/4EP8YzcN0hQ?t=1486)
- [Input and Output in Java](https://youtu.be/TAtrPoaJ7gc)
- [First Java Program](https://youtu.be/TAtrPoaJ7gc)
- [Input and Output in Java](https://youtu.be/TAtrPoaJ7gc?t=2086)
- [Conditionals & Loops in Java](https://youtu.be/ldYLYRNaucM?t=88)
- [if-else](https://youtu.be/ldYLYRNaucM?t=88)
- [loops](https://youtu.be/ldYLYRNaucM?t=440)
Expand Down Expand Up @@ -127,12 +128,12 @@
- [Reversal of LinkedList](https://youtu.be/70tx7KcMROc)
- [Linked List + Recursion](https://youtu.be/70tx7KcMROc)
- Stacks & Queues
- Introduction
- Interview problems
- Push efficient
- Pop efficient
- [Introduction](https://youtu.be/rHQI4mrJ3cg)
- [Push efficient](https://youtu.be/rHQI4mrJ3cg)
- [Pop efficient](https://youtu.be/rHQI4mrJ3cg)
- [Circular Queue](https://youtu.be/rHQI4mrJ3cg)
- Queue using Stack and Vice versa
- Circular Queue
- Interview problems
- Trees
- Introduction
- Binary Trees
Expand Down
16 changes: 16 additions & 0 deletions assignments/15-linkedlist.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
- [Intersection of Two Linked Lists](https://leetcode.com/problems/intersection-of-two-linked-lists/) `leetcode`
- [Linked List Cycle](https://leetcode.com/problems/linked-list-cycle/) `leetcode` `Samsung`
- [Remove Duplicates from Sorted List](https://leetcode.com/problems/remove-duplicates-from-sorted-list/)`leetcode`
- [Find All Numbers Disappeared in an Array](https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/) `leetcode`
- [Remove Linked List Elements](https://leetcode.com/problems/remove-linked-list-elements/) `leetcode`

## Medium
- [Design Twitter](https://leetcode.com/problems/design-twitter/) `leetcode`
- [ Design Linked List](https://leetcode.com/problems/design-linked-list/) `leetcode`
- [Reverse Linked List II](https://leetcode.com/problems/reverse-linked-list-ii/) `leetcode`
- [Reorder List](https://leetcode.com/problems/reorder-list/) `leetcode`
- [Remove Nth Node From End of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list/) `leetcode` `HSBC`
Expand All @@ -29,6 +32,19 @@
- [Partition list](https://leetcode.com/problems/partition-list/) `leetcode`
- [Find first node of loop in a linked list](https://www.geeksforgeeks.org/find-first-node-of-loop-in-a-linked-list/) `GFG`
- [Swap Nodes in Pairs](https://leetcode.com/problems/swap-nodes-in-pairs/)`leetcode`
- [Remove Zero Sum Consecutive Nodes from Linked List](https://leetcode.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list/) `leetcode`
- [Insertion Sort List](https://leetcode.com/problems/insertion-sort-list/)`leetcode`
- [ Reverse Nodes in Even Length Groups](https://leetcode.com/problems/reverse-nodes-in-even-length-groups/)`leetcode`
- [ Linked List Random Node](https://leetcode.com/problems/linked-list-random-node/)`leetcode`
- [Sort List](https://leetcode.com/problems/sort-list/)`leetcode`
- [ Merge In Between Linked Lists](https://leetcode.com/problems/merge-in-between-linked-lists/)`leetcode`
- [Design Browser History](https://leetcode.com/problems/design-browser-history/)`leetcode`
- [Delete the Middle Node of a Linked List](https://leetcode.com/problems/delete-the-middle-node-of-a-linked-list/)`leetcode`
- [Next Greater Node In Linked List](https://leetcode.com/problems/next-greater-node-in-linked-list/)`leetcode`
- [ Odd Even Linked List](https://leetcode.com/problems/odd-even-linked-list/)`leetcode`
- [Linked List Random Node](https://leetcode.com/problems/linked-list-random-node/)`leetcode`
- [Split Linked List in Parts](https://leetcode.com/problems/split-linked-list-in-parts/)`leetcode`
- [ Find the Minimum and Maximum Number of Nodes Between Critical Points](https://leetcode.com/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/)`leetcode`

## Hard
- [Reverse Nodes in k-Group](https://leetcode.com/problems/reverse-nodes-in-k-group/) `leetcode`
Expand Down
Binary file not shown.
3 changes: 3 additions & 0 deletions lectures/19-stacks-n-queues/code/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lectures/19-stacks-n-queues/code/.idea/description.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions lectures/19-stacks-n-queues/code/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions lectures/19-stacks-n-queues/code/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions lectures/19-stacks-n-queues/code/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lectures/19-stacks-n-queues/code/.idea/project-template.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions lectures/19-stacks-n-queues/code/.idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions lectures/19-stacks-n-queues/code/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions lectures/19-stacks-n-queues/code/code.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
69 changes: 69 additions & 0 deletions lectures/19-stacks-n-queues/code/src/com/kunal/CircularQueue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package com.kunal;

public class CircularQueue {
protected int[] data;
private static final int DEFAULT_SIZE = 10;

protected int end = 0;
protected int front = 0;
private int size = 0;

public CircularQueue(){
this(DEFAULT_SIZE);
}

public CircularQueue(int size) {
this.data = new int[size];
}

public boolean isFull() {
return size == data.length; // ptr is at last index
}

public boolean isEmpty() {
return size == 0;
}

public boolean insert(int item) {
if (isFull()) {
return false;
}
data[end++] = item;
end = end % data.length;
size++;
return true;
}

public int remove() throws Exception {
if (isEmpty()) {
throw new Exception("Queue is empty");
}

int removed = data[front++];
front = front % data.length;
size--;
return removed;
}

public int front() throws Exception{
if (isEmpty()) {
throw new Exception("Queue is empty");
}
return data[front];
}

public void display() {
if (isEmpty()) {
System.out.println("Empty");
return;
}
int i = front;
do {
System.out.print(data[i] + " -> ");
i++;
i %= data.length;
} while (i != end);
System.out.println("END");
}

}
63 changes: 63 additions & 0 deletions lectures/19-stacks-n-queues/code/src/com/kunal/CustomQueue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.kunal;

public class CustomQueue {
private int[] data;

private static final int DEFAULT_SIZE = 10;

int end = 0;

public CustomQueue(){
this(DEFAULT_SIZE);
}

public CustomQueue(int size) {
this.data = new int[size];
}

public boolean isFull() {
return end == data.length; // ptr is at last index
}

public boolean isEmpty() {
return end == 0;
}

public boolean insert(int item) {
if (isFull()) {
return false;
}
data[end++] = item;
return true;
}

public int remove() throws Exception {
if (isEmpty()) {
throw new Exception("Queue is empty");
}

int removed = data[0];

// shift the elements to left
for (int i = 1; i < end; i++) {
data[i-1] = data[i];
}
end--;
return removed;
}

public int front() throws Exception{
if (isEmpty()) {
throw new Exception("Queue is empty");
}
return data[0];
}

public void display() {
for (int i = 0; i < end; i++) {
System.out.print(data[i] + " <- ");
}
System.out.println("END");
}

}
Loading

0 comments on commit b058125

Please sign in to comment.