Skip to content

Instantly share code, notes, and snippets.

View rishabhverma17's full-sized avatar
💭
I may be slow to respond.

Rishabh Verma rishabhverma17

💭
I may be slow to respond.
View GitHub Profile
@rishabhverma17
rishabhverma17 / chatengine-embed-0-1-barebones-chat.markdown
Last active November 30, 2017 07:24
ChatEngine Embed 0.1 - Barebones Chat
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;
}
@rishabhverma17
rishabhverma17 / AddTwoList.java
Created June 2, 2019 18:09
Add Two LinkedList to form resultant list.
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);
@rishabhverma17
rishabhverma17 / TwoSum.java
Created June 2, 2019 18:10
Find two number with target sum
/*
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;
@rishabhverma17
rishabhverma17 / tries_Trie.java
Created September 22, 2019 16:08
Implementation of Tries with Shortest Unique Prefix in Java
package com.tries;
import java.util.ArrayList;
class Trie{
private final TrieNode root;
Trie(){
this.root = new TrieNode();
}