Java program to find the maximum and minimum elements in a stack

Pranay Arora
Updated on 18-Aug-2024 00:20:08

8 Views

Stacks are basic data structures that follow the Last in First Out principle also termed as LIFO. A stack has many use cases like organizing function calls and undoing actions. Often one might encounter a problem locating the biggest and smallest elements inside a stack, this article will demonstrate multiple methods to accomplish this task using Java. Understanding Stacks A stack is a linear data structure that allows operations at only one end, known as the top. The primary operations include: Push: Adding an element to the top of the stack. ... Read More

Send SMS Alert to saved contact in Java

Harsh Laghave
Updated on 17-Aug-2024 21:29:32

29 Views

Steps to Send SMS Alerts Using Java In this article, we'll explore how to send SMS alerts to saved contacts using Java. We will guide you on how to Send SMS alerts using Java to saved or unsaved Contacts. Following are the steps to do so − Setting up an account with the SMS provider. Adding provider Java library to your project. Writing Java code to send the SMS. Let's elaborate on the above steps. Setting up Account First of all, we need to set up ... Read More

Explore our latest online courses and learn new skills at your own pace. Enroll and become a certified expert to boost your career.

Java program to find the smallest missing number

Shiva Keerthi
Updated on 16-Aug-2024 23:25:28

838 Views

The smallest missing number is the smallest number that is missing from a stream of elements or in an Array. The stream may or may not contain continuous elements. If the stream is continuous then the smallest missing number is nothing but the Smallest Missing Number in a stream. In this section, we will discuss the various approaches to find a Smallest Missing Number in a stream of elements using Java programming language. Problem Statement Given a stream of integers find the smallest missing number from the stream. Input 1 arr=[1, 2, 3, 5, 6, 7, 8] Output 1 ... Read More

Java program to print all unique words of a string

George John
Updated on 16-Aug-2024 23:25:13

1K+ Views

In this article, we will learn to find unique words in a string using the Map utility of Java because of its property that it does not contain duplicate keys. To find unique words first get all words in the array to compare each word, for this split string based on space/s. If other characters such as comma(, ) or full stop (.) are present then using required regex first replace these characters from the string. Insert each word of string as the key of Map and provide the initial value corresponding to each key as is unique if this ... Read More

Java program to get highest key stored in TreeMap

Samual Sam
Updated on 16-Aug-2024 23:24:59

1K+ Views

In this article, we will learn how to retrieve the highest key stored in a TreeMap. We will create a simple Java program that demonstrates how to create a TreeMap, add key-value pairs to it, and then use the lastKey() method to find the highest key in the map. Problem Statement Write a Java program to get the highest key stored in TreeMap. Input {1=PHP, 2=jQuery, 3=JavaScript, 4=Ruby, 5=Java, 6=AngularJS, 7=ExpressJS} Output Highest key in TreeMap: 7 Steps  The followingare the steps to get the highest key in TreeMap − First, import the classes. ... Read More

Java program to swap two integers

Chandu yadav
Updated on 16-Aug-2024 23:24:32

2K+ Views

In this article, we will learn to swap two numbers using Java. We will use the Scanner class to get the user input and perform the swapping temporary variable. Read integers from users using the nextInt() method of the Scanner class. Steps to swap two integers Following are the steps to swap two numbers in Java− Import the Scanner class. Create a variable (temp), and initialize it with 0. Assign 1st number to temp. Assign the 2nd number to the 1st number. ... Read More

How to rotate an element using CSS?

Shabaz Alam
Updated on 16-Aug-2024 18:07:49

7K+ Views

To rotate an element using CSS, is a powerful tool to control and enhance the visual presentation of a website. In this article, we will be understanding three different approaches to rotate an element Using CSS. We are having an image and a div box with text content written in it, our task is to rotate element using CSS. Approaches to Rotate an Element Using CSS Here is a list of approaches to rotate an element using CSS which we will be discussing in this article with stepwise explaination and complete example codes. Rotate using ... Read More

Applying Python programming to solve Mechanical Engineering Problems

Pankaj Dumka
Updated on 16-Aug-2024 12:10:45

49 Views

Using Python Programming to solve PDV work problems In cases of closed systems which are also called as systems where the identity of mass does not change, the system interacts with its surroundings either in terms of heat or work. In this article, we will be dealing with the non-dissipative work interaction which is also known as the PDV or displacement work. We will be using Python programming to solve these problems. But before we start, one should know the fundamental meaning of displacement work. The displacement work is evaluated as the integral of the path the system has taken ... Read More

How can I force PHP to use strings for array keys?

Timpol
Updated on 16-Aug-2024 10:35:03

7 Views

To force PHP to use strings for array keys is quite easy, as in PHP array keys are automatically stored as integers if the array elements are numbers. If they are not numbers then it will cast to strings. Forcing PHP to Use strings for Array Keys Following are the ways to force PHP to use strings for array Keys Using php array() function Using json_encode() function Using php array() Function If you use the array() function and keep the first key in quotes it will take other keys as a string does not matter if you are ... Read More

JavaScript Program for Left Rotation and Right Rotation of a String

Shriansh Kumar
Updated on 16-Aug-2024 08:18:02

806 Views

We are given a String and an integer value. The integer indicates how many times we have to rotate the string in left and right direction. In the left rotation, move the String characters in anti-clockwise from the prefix side and add them to the suffix side. Similarly, in right rotation, move the characters of the given string in clockwise and pick the characters from the suffix and add them to the prefix of the string. In this article, we will implement the JavaScript program for the left rotation and right rotation of a given string. The length of ... Read More

1 2 3 4 5 ... 10855 Next
Advertisements