/**
 * Company
 * Copyright (C) 2014-2017 All Rights Reserved.
 */
package com.cwenao.trying.stackandqueue;

/**
 * @author cwenao
 * @version $Id GFG.java, v 0.1 2017-09-23 13:31 cwenao Exp $$
 */
public class GFG {
    private class DLLNode {
        DLLNode preNode;
        DLLNode next;
        int data;

        DLLNode(int data) {
            this.data = data;
        }
    }
}

@@ -378,10 +378,1672 @@
 %7D%0A    %7D%0A
+%0A    private class MyStack %7B%0A        DLLNode head;%0A        DLLNode mid;%0A        int count;%0A    %7D%0A%0A    public MyStack createMyStack() %7B%0A        MyStack myStack = new MyStack();%0A        myStack.count = 0;%0A        return myStack;%0A    %7D%0A%0A    public void push(MyStack myStack, int data) %7B%0A%0A        DLLNode dllNode = new DLLNode(data);%0A        dllNode.preNode = null;%0A        dllNode.next = myStack.head;%0A        myStack.count += 1;%0A%0A        if (myStack.count == 1) %7B%0A            myStack.mid = dllNode;%0A        %7D else %7B%0A            myStack.head.preNode = dllNode;%0A            if (myStack.count %25 2 !=0) %7B%0A                myStack.mid = myStack.mid.preNode;%0A            %7D%0A        %7D%0A%0A        myStack.head = dllNode;%0A    %7D%0A%0A    public int pop(MyStack myStack) %7B%0A%0A        if (myStack == null) %7B%0A            return -1;%0A        %7D%0A%0A        DLLNode dllNode = myStack.head;%0A        int data = dllNode.data;%0A        myStack.head = dllNode.next;%0A%0A        if (myStack.head !=null) %7B%0A            myStack.head.preNode = null;%0A        %7D%0A        myStack.count -= 1;%0A%0A        if (myStack.count %25 2 == 0) %7B%0A            myStack.mid = myStack.mid.next;%0A        %7D%0A%0A        return data;%0A%0A    %7D%0A%0A    public int getMid(MyStack myStack) %7B%0A        if (myStack.mid == null) %7B%0A            return -1;%0A        %7D%0A        return myStack.mid.data;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        GFG gfg = new GFG();%0A        MyStack myStack = gfg.createMyStack();%0A        gfg.push(myStack, 1);%0A        gfg.push(myStack, 5);%0A        gfg.push(myStack, 30);%0A        gfg.push(myStack, 45);%0A%0A        System.out.println(gfg.getMid(myStack));%0A        System.out.println(gfg.pop(myStack));%0A%0A    %7D%0A%0A
 %7D%0A

update the gfg