This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package deleteNode; | |
import java.awt.List; | |
public class deleteNode { | |
private static final ListNode l6 = null; | |
public static boolean deleteNode(ListNode n){ | |
if(n==null||n.next==null){ | |
return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.List; | |
public class ListPartition { | |
public static void ListPartition(ListNode node, int x){ | |
ListNode beforeStart=null; | |
ListNode afterStart=null; | |
while (node!=null){ | |
ListNode next=node.next; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package addList; | |
import java.awt.List; | |
import java.util.*; | |
public class addList { | |
public ListNode addLists(ListNode l1, ListNode l2,int carry ){ | |
if(l1==null&&l2==null&&carry==0){/*if l1=l2=null, return null*/ | |
return null; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.List; | |
import java.util.*; | |
public class findBenning { | |
public static ListNode findBeginning(ListNode head){ | |
ListNode slow=head; | |
ListNode fast=head; | |
while(fast!=null&&fast.next!=null){ | |
slow=slow.next; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Stack; | |
public class isPalindrome { | |
public static boolean isPalindrome(ListNode head){ | |
ListNode fast=head; | |
ListNode slow=head; | |
Stack<Integer> stack=new Stack<Integer>(); | |
while(fast!=null&&fast.next!=null){ | |
stack.push(slow.data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import java.awt.*; | |
import java.*; | |
public class StackData { | |
int stackSize=150; | |
int[] buffer=new int[stackSize*3]; | |
int[] stackPointer={-1,-1,-1}; | |
void push(int stackNumber, int value) throws Excpetion{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Stack; | |
public class StackWithMin extends Stack<Integer>{ | |
Stack<Integer> s2; | |
public StackWithMin(){ | |
s2=new Stack<Integer>(); | |
} | |
public void push(int value){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Stack; | |
class MyQueue<T> { | |
// push stack | |
private Stack<T> s0; | |
// poll stack | |
private Stack<T> s1; | |
private int number; | |
public MyQueue() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class stack{ | |
public static Stack<Integer> sort(Stack<Integer> s) { | |
Stack<Integer> r = new Stack<Integer>(); | |
while (!s.isEmpty()) { | |
int tmp= s.pop(); | |
while (!r.isEmpty() && r.peek() > tmp) { | |
s.push(r.pop()); | |
} | |
r.push(tmp); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Animal { | |
String type; | |
Date arrive; | |
String name; | |
} | |
public class Cats extends Animal{ | |
public Cats(String name){ | |
this.name=name; | |
type="cats"; |