#
java programs Archive

In this post, we will see Java program to find number of words in a String. Problem Find the number of words in a String. For example: There are 6 words in below String welcome …

Kadane algorithm is a famous algorithm to solve maximum subarray problem. Maximum subArray problem: From Wikipedia : In computer science, the maximum subarray problem is the task of finding the contiguous subarray within a one-dimensional …

If you want to practice data structure and algorithm programs, you can go through data structure and algorithm interview questions. In this post, we will see how to check for balanced parentheses in an expression. Lets …

In this post, we will see how to remove all white spaces from String in java. There are multiple ways to remove spaces from String. Using ReplaceAll Using Iteration Using ReplaceAll : You can simply …

Fibonacci series is numerical series in which next number is sum of previous two numbers. For example : 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 etc. There are two ways to …

Armstrong number is a 3 digit number which is equal to sum of cube of its digits. For example: 371,153 In this post, we will see how to check for Armstrong number in java. …

In this post, we will see how to swap two numbers without using temporary variables. There are three ways to do it. Java program: When you run above program, you will get following output: …

In this post, we will see how to find Greatest common divisor(GCD) and Least Common Multiple(LCM) in java. GCD is calculated using Euclidean algorithm and LCM is calculated using reduction by GCD Eucid algo for …

If you want to practice data structure and algorithm programs, you can go through data structure and algorithm interview questions. In this post, we will see how to find transpose of matrix in java. Transpose of …

Given array of integers, find Maximum difference between two elements such that larger element appears after the smaller number For example: Algorithm: Lets say we have array arr of stock prices. We will track two variable :minElementTillNow and maxDifference. …