Skip to content

Instantly share code, notes, and snippets.

View hilda8519's full-sized avatar
🎯
Focusing

hilda8519's GitHub hilda8519

🎯
Focusing
  • san jose,ca,usa
View GitHub Profile
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);
}
import java.util.Stack;
class MyQueue<T> {
// push stack
private Stack<T> s0;
// poll stack
private Stack<T> s1;
private int number;
public MyQueue() {
import java.util.Stack;
public class StackWithMin extends Stack<Integer>{
Stack<Integer> s2;
public StackWithMin(){
s2=new Stack<Integer>();
}
public void push(int value){
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{
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);
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;
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;
}
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;
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;
package nthToLast;
import java.awt.List;
import java.util.*;
public class nthToLast {
public static <ListNode> int nthToL(ListNode head, int k){
if(head==null){
return 0;