ChatEngine Core Chat
A Pen by Rishabh Verma on CodePen.
ChatEngine Core Chat
A Pen by Rishabh Verma on CodePen.
package com.stacks; | |
import java.util.ArrayList; | |
public class ListStacks<X> implements Stack { | |
private ArrayList<X> listStack = new ArrayList<>(); | |
private int stackPointer; | |
@Override | |
public void push(Object newItem) { |
package com.queues; | |
public class BasicQueue<X> implements Queue<X> { | |
private X[] data; | |
private int front; | |
private int end; | |
public BasicQueue(){ | |
this.data = (X[]) new Object[1000]; | |
this.front = -1; |
package com.linkedList; | |
public interface I_LinkedList<X> { | |
int size(); | |
void add(X item); | |
X remove(); | |
void insert(X item, int position); |
package com.hashTable; | |
public class BasicHashTable<X,Y> implements HashTable<X, Y> { | |
private HashEntry[] data; | |
private int capacity; | |
private int size; | |
public BasicHashTable(int tableSize) { | |
this.capacity = tableSize; |
package com.binaryTree; | |
public class BasicBinaryTree<X extends Comparable<X>> implements BinaryTree<X> { | |
private Node root; | |
private int size; | |
public BasicBinaryTree() { | |
this.root = null; | |
this.size = 0; | |
} |
class AddTwoList { | |
ListNode head1, head2; | |
public static void main(String[] args) { | |
AddTwoList list = new AddTwoList(); | |
// creating first list | |
list.head1 = new ListNode(7); | |
list.head1.next = new ListNode(5); | |
list.head1.next.next = new ListNode(9); |
/* | |
Given an array of integers, return indices of the two numbers such that they add up to a specific target. | |
You may assume that each input would have exactly one solution, and you may not use the same element twice. | |
Example: | |
Given nums = [2, 7, 11, 15], target = 9, | |
Because nums[0] + nums[1] = 2 + 7 = 9, | |
return [0, 1]. |
public ListNode rotateRight(ListNode head, int k) { | |
ListNode start = head; | |
ListNode slow = head; | |
ListNode fast = head; | |
ListNode temp = head; | |
int listCount = 0; | |
if (k == 0) return head; | |
if (head == null) return null; | |
if (head.next == null) return head; |
package com.tries; | |
import java.util.ArrayList; | |
class Trie{ | |
private final TrieNode root; | |
Trie(){ | |
this.root = new TrieNode(); | |
} |