Skip to content

Instantly share code, notes, and snippets.

@code4sharing
code4sharing / AngryProfessor.java
Created August 12, 2015 11:22
Angry Professor problem hackerrank
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
@code4sharing
code4sharing / BigIntFactorial.java
Created August 12, 2015 11:17
Extra long factorials
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
@code4sharing
code4sharing / ReverseDoublyLinkedList.java
Created August 12, 2015 11:13
Reverse a doubly linked list
/*
Insert Node at the end of a linked list
head pointer input could be NULL as well for empty list
Node is defined as
class Node {
int data;
Node next;
Node prev;
}
*/
@code4sharing
code4sharing / InsertDoubleLinkedList.java
Created August 12, 2015 11:10
Insert into double sorted list
/*
Insert Node at the end of a linked list
head pointer input could be NULL as well for empty list
Node is defined as
class Node {
int data;
Node next;
Node prev;
}
*/
@code4sharing
code4sharing / MergePoint.java
Created August 12, 2015 11:05
Find merge point between two linkedlist
/*
Insert Node at the end of a linked list
head pointer input could be NULL as well for empty list
Node is defined as
class Node {
int data;
Node next;
}
*/
int FindMergeNode(Node headA, Node headB) {
@code4sharing
code4sharing / DetectCycle.java
Created August 12, 2015 11:01
Detect Cycle
/*
Insert Node at the end of a linked list
head pointer input could be NULL as well for empty list
Node is defined as
class Node {
int data;
Node next;
}
*/
int HasCycle(Node head) {
@code4sharing
code4sharing / Delete_Duplicate.java
Created August 12, 2015 10:53
Delete duplicate value from linkedlist
/*
Node is defined as
class Node {
int data;
Node next;
}
*/
Node RemoveDuplicates(Node head) {
// This is a "method-only" submission.
@code4sharing
code4sharing / GetNodeValue.java
Created August 12, 2015 10:49
Get Node Value
/*
Insert Node at the end of a linked list
head pointer input could be NULL as well for empty list
Node is defined as
class Node {
int data;
Node next;
}
*/
@code4sharing
code4sharing / Merge.java
Created August 12, 2015 10:45
Merge two LinkedList
/*
Insert Node at the end of a linked list
head pointer input could be NULL as well for empty list
Node is defined as
class Node {
int data;
Node next;
}
*/
@code4sharing
code4sharing / Compare.java
Created August 12, 2015 10:42
Compare two linked lists
/*
Insert Node at the end of a linked list
head pointer input could be NULL as well for empty list
Node is defined as
class Node {
int data;
Node next;
}
*/
int CompareLists(Node headA, Node headB) {