Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

remove minimum element from stack java

public static void removeMin(Stack stack) {
        int min = stack.readTop(); 
        int e;
        Stack newStack1 = new Stack(7); //7 is the size of the stack
        while (!stack.isEmpty()) {
            e = stack.pop(); 
            newStack1.push(e); 
            
            if (e < min) {
                min = e;
            }
        }

        System.out.println("
Min element: " + min);

        while (!newStack1.isEmpty()) {
            e = newStack1.pop(); 
            
            if (e != min) {
                stack.push(e);
            }
        }
    }
Comment

PREVIOUS NEXT
Code Example
Java :: java get the closest pair to a given sum in two arrays 
Java :: stackoverflow java enum with constructor 
Java :: Quartz spring maven driver 
Java :: difference between set and list in java 
Java :: ignore sonarlint line java 
Java :: reset a jTable without deleting rows 
Java :: priority queue is empty java 
Java :: tree algorithm example 
Java :: format code netbean 
Java :: java ultimo dia del mes 
Java :: Java Constructor invocations 
Java :: tomcat allow remote access to manager 
Java :: org.springframework.data.mapping.model.mappinginstantiationexception: failed to instantiate java.util.list using constructor no_constructor with arguments 
Java :: java equivalent of pythons getattr 
Java :: sort stream by key java 
Java :: simple example of adding two number by calling a method 
Java :: grepper editor 
Java :: java cors issue 
Java :: resultset previous 
Java :: how to romve a element from arraylist in java 
Java :: Using UUID spring boot Neo4J 
Java :: room ktx dependency 
Java ::         System.out.println("Welcome to GeeksforGeeks"); 
Java :: Dio.java 
Java :: how does minus works in Java 
Java :: code converter python to java 
Java :: save ArrayList into Room Database android studio 
Java :: how to make edittext not editable in android studio 
Java :: test spring cloud stream 
Java :: java.lang.NullPointerException at org.openqa.selenium.support.pagefactory.findElement(DefaultElementLocator.java:69) 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =