Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4eab2e3
added preparation folders
emil-ep Mar 30, 2021
7768774
updated the demoable sections
Mar 31, 2021
50918a8
updated test files for interview preparation
emil-ep Apr 20, 2021
7cefdd4
updated interview
emil-ep Apr 21, 2021
9bf10d1
updated interview qustions
emil-ep May 27, 2021
5ec50c5
added template pattern
emil-ep Aug 10, 2021
ae6ab5f
added template pattern to interview
emil-ep Aug 15, 2021
f7f26a2
working on custom data structure implementations
emil-ep Aug 15, 2021
9820798
updating implementation of priority queue
emil-ep Aug 23, 2021
c359147
added leetcode questions
emil-ep Aug 27, 2021
62cfd22
added sum of linkedlist code
emil-ep Aug 28, 2021
b54f24e
updated interview code
emil-ep Sep 15, 2021
43908ce
added text parsing
emil-ep Dec 2, 2021
4eb94f9
abstraction changes
emil-ep Jan 9, 2022
0065fd8
added turn matrix by 90 degree problem
emil-ep Mar 5, 2022
8c6f776
added problems
emil-ep Mar 6, 2022
c045d3e
added breadth first search and depth first search
emil-ep Mar 8, 2022
c577526
added problems to interview preparation
emil-ep Mar 11, 2022
94439d2
added validate balanced tree
emil-ep Mar 11, 2022
7518821
added dynamic programming related question
emil-ep Mar 24, 2022
16a7739
updated
georgentid Feb 5, 2023
d371b6b
needle in haystack
georgentid Feb 6, 2023
d7a8290
added an example for generics
georgentid Apr 11, 2023
04d96a2
updated
georgentid May 22, 2023
a9c1ca4
added more cases
georgentid May 25, 2023
16618f3
pudate
georgentid May 30, 2023
7097e7b
added sealed class
georgentid Jul 6, 2024
5295e48
added for interview
emil-ep Nov 8, 2025
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
14 changes: 14 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>


<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -46,6 +53,13 @@
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.innoventes.jukebox.crackingcodinginterview.queue.queuewith2stack;

import java.util.EmptyStackException;
import java.util.Stack;

public class MyQueue<T> {

private Stack<T> inStack;
private Stack<T> outStack;

public MyQueue() {
this.inStack = new Stack<>();
this.outStack = new Stack<>();
}

public void push(T item){
this.inStack.push(item);
}


public T pop(){
if (outStack.size() == 0 && inStack.size() == 0){
throw new EmptyStackException();
}
if (outStack.size() != 0){
return outStack.pop();
}
int size = inStack.size();
for (int i = 0; i < size; i++){
T item = inStack.pop();
outStack.push(item);
}
return outStack.pop();
}

public boolean empty(){
if (outStack.size() == 0 && inStack.size() == 0){
return true;
}
return false;
}

public T peek(){
if (outStack.size() == 0 && inStack.size() == 0){
throw new EmptyStackException();
}
if (outStack.size() != 0){
return outStack.peek();
}
int size = inStack.size();
for (int i = 0; i < size; i++){
T item = inStack.pop();
outStack.push(item);
}
return outStack.peek();
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.innoventes.jukebox.crackingcodinginterview.queue.queuewith2stack;

public class QueueExecutor {

public static void main(String[] args) {
MyQueue<Integer> myQueue = new MyQueue<>();
myQueue.push(1);
myQueue.push(2);
myQueue.push(3);
myQueue.push(4);

System.out.println(myQueue.peek());

System.out.println(myQueue.pop());
System.out.println(myQueue.pop());

myQueue.push(5);

System.out.println(myQueue.pop());
System.out.println(myQueue.pop());
System.out.println(myQueue.pop());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.innoventes.jukebox.crackingcodinginterview.stack.custom;

import java.util.EmptyStackException;

public class CustomStack<T> {


private static class StackNode<T> {

private T data;
private StackNode<T> next;

public StackNode(T data) {
this.data = data;
}
}

private StackNode<T> top;

public void push(T item){
StackNode<T> t = new StackNode<>(item);
t.next = top;
top = t;
}

public T pop(){
if (top == null) throw new EmptyStackException();
T item = top.data;
top = top.next;
return item;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.innoventes.jukebox.crackingcodinginterview.stack.custom;

public class StackExecutor {

public static void main(String[] args) {
CustomStack<Integer> customStack = new CustomStack<>();
customStack.push(1);
customStack.push(2);
customStack.push(3);



System.out.println(customStack.pop());
System.out.println(customStack.pop());
System.out.println(customStack.pop());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.innoventes.jukebox.crackingcodinginterview.stack.sort;

import java.util.Scanner;
import java.util.Stack;

//Sort a stack using only another temporary data structure
public class SortStack {


public static void main(String[] args) {

Stack<Integer> inputStack = new Stack<>();
System.out.println("Enter the size of stack :");
Scanner scanner = new Scanner(System.in);
int size = scanner.nextInt();
System.out.println("Enter the stack elements");
for (int i = 0; i < size; i++){
int item = scanner.nextInt();
inputStack.push(item);
}
System.out.println("The sorted stack is as follows");
printSortedStack(inputStack);
}

private static void printSortedStack(Stack<Integer> inputStack){
Stack<Integer> tempStack = new Stack<>();
int temp = inputStack.pop();
tempStack.push(temp);
while (!inputStack.isEmpty()){
temp = inputStack.pop();
while (!tempStack.isEmpty() && temp < tempStack.peek()){
int tempItem = tempStack.pop();
inputStack.push(tempItem);
}
tempStack.push(temp);
}
while (!tempStack.isEmpty()){
inputStack.push(tempStack.pop());
}
while (!inputStack.isEmpty()){
System.out.println(inputStack.pop());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.innoventes.jukebox.crackingcodinginterview.string;

public class StringPermuationCheck {


public static void main(String[] args) {
String s = "abc";
String s1 = "cba";

char[] sChars = s.toCharArray();
if (s.length() != s1.length()){
System.out.println("Not a permutation");
}
for (char w : sChars){
if (s1.contains(String.valueOf(w)))
continue;
else {
System.out.println("Not a permutation");
break;
}
}
}
}
99 changes: 99 additions & 0 deletions src/main/java/com/innoventes/jukebox/leetcode/TwoSum.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package com.innoventes.jukebox.leetcode;

import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;

public class TwoSum {

public static class ListNode {
int val;
ListNode next;

ListNode() {
}

ListNode(int val) {
this.val = val;
}

ListNode(int val, ListNode next) {
this.val = val;
this.next = next;
}
}

public static void main(String[] args) {

ListNode l11 = new ListNode(2);
ListNode l12 = new ListNode(4);
ListNode l13 = new ListNode(3);
l12.next = l13;
l11.next = l12;

ListNode l21 = new ListNode(5);
ListNode l22 = new ListNode(6);
ListNode l23 = new ListNode(4);
l22.next = l23;
l21.next = l22;

ListNode result = findSum(l11, l21);
System.out.println(result);
}

private static ListNode findSum(ListNode l1, ListNode l2){
Queue<Integer> l1Queue = new LinkedBlockingQueue<>();
Queue<Integer> l2Queue = new LinkedBlockingQueue<>();

while(l1.next != null){
l1Queue.add(l1.val);
l1 = l1.next;
}
l1Queue.add(l1.val);

while(l2.next != null){
l2Queue.add(l2.val);
l2 = l2.next;
}
l2Queue.add(l2.val);

int maxSize = Math.max(l1Queue.size(), l2Queue.size());

int carryOver = 0;
int totalSum = 0;
for (int i = 0; i < maxSize; i++){
int l1Number = 0;
int l2Number = 0;
if(!l1Queue.isEmpty()){
l1Number = l1Queue.poll();
}
if (!l2Queue.isEmpty()){
l2Number = l2Queue.poll();
}
int sum = l1Number + l2Number + carryOver;
if (sum > 10){
carryOver = 1;
sum = sum - 10;
}else if(sum == 10){
carryOver = 10;
}else{
carryOver = 0;
}
int dividend = (int) Math.pow(10, i);

totalSum = totalSum + (sum * (dividend));
System.out.println(totalSum);
}
ListNode finalNode = null;
int remainder = 0;
int i = 1;
boolean continueLoop = true;
while (totalSum / 10 != 0){
remainder = totalSum % 10;
totalSum = totalSum / 10;
finalNode = new ListNode(remainder, finalNode);
}
remainder = totalSum % 10;
finalNode = new ListNode(remainder, finalNode);
return finalNode;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.innoventes.jukebox.test;

@FunctionalInterface
public interface FunctionalInterface1 {

void print();

default int sum(int a, int b){
return a + b;
}

static int square(int a){
return a * a;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.innoventes.jukebox.test;

public interface FunctionalInterface2 {

void print();
}
10 changes: 10 additions & 0 deletions src/main/java/com/innoventes/jukebox/test/InterfaceTestClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.innoventes.jukebox.test;

public class InterfaceTestClass implements FunctionalInterface1, FunctionalInterface2{


@Override
public void print() {
System.out.println("Printing from functional interface");
}
}
Loading