Web Rewrite
Technology Blog Where You Find Programming Tips and Tricks
  Menu
Skip to content
  • Home
  • Java
  • Programming Questions
    • Array
    • Linked List
    • Stack
    • Queue
    • String
    • Search Algo
    • Interview Questions
  • Solid Principles
  • Multithreading
  • PHP
  • Database
    • mysql
    • MongoDB
  • Contact Us

Tag Archives: Maximum Element in a Stack

Find the Maximum Element in a Stack in O(1)

By WebRewrite | March 8, 2022 - 8:58 am |March 8, 2022 InterviewQuestions, Java, programming, Stack
Leave a comment

Find the maximum element in a stack in O(1) (constant time).

Design a stack to get the maximum element from a stack in constant time.

For example:

To understand this problem, let’s take an example. Suppose, the following elements are pushed in a stack.

→
Tagged Java, Maximum Element in a Stack, Stack
  • Support Me on PayPal

    Programming Video Tutorials


  • Related Posts (YARPP)

    1. How to Access Localhost from Anywhere using Any Device
    2. How To Install PHP, MySql, Apache (LAMP) in Ubuntu
    3. How to Copy File in Linux using CP Command
    4. PHP Composer : Manage Package Dependency in PHP
  • Topics

    • Multithreading

    • Linked List

    • Binary Tree

    • Hash Map

    • Java

    • Queue

    • Stack

    • Binary Search

    • Programming

    • Sliding Window

    • Composer

    • Memcache

    • Javascript

    • Solid Principles

  • Copyright 2020 – 2021 – webrewrite.com – All Rights Reserved.

  • Home
  • Java
  • Programming Questions
  • Solid Principles
  • Multithreading
  • PHP
  • Database
  • Contact Us
Web Rewrite | Powered by Mantra & WordPress.