Check for Balanced Parentheses using Stack – Java Code

Write a java code to check for balanced parentheses using stack. Given an expression containing characters ‘{‘,’}’,'(‘,’)’,'[‘,’]’. We have to write a java code to check whether an input string has valid parentheses.

An input string is valid if:

Open brackets must be closed by the same type of brackets.
Open brackets must be closed in the correct order.

Example –

i) {[]}) – Invalid
ii) {()}[] – Valid

Java Program to Calculate Power of a Number

In this tutorial, I am going to explain how to calculate power of a number without using Math.pow method in java.

For example:

i) 23 = 8 (2 * 2 * 2)
ii) 52 = 25 (5 * 5)

Subscribe Our Tutorials

Get Latest Updates on Facebook

Swap Two Numbers in PHP – Explain with Code Examples

Write a PHP script to swap two numbers. In this tutorial, we are going to write a code to swap two numbers in PHP.

There are multiple approaches by which you can swap two numbers.

i) We can swap two numbers using third or temp variable.

ii) We can swap two numbers without using third variable.