Bubble Sort Program in Java

In this tutorial, We are going to learn bubble sort algorithm and it’s implementation in java. We are going to discuss following points in this tutorial.

i) Bubble Sort Algorithm.
ii) Bubble sort program in java (How we can sort an unsorted array using bubble sort algorithm).
iii) Bubble sort video tutorial.

Find First Non-repeating Character in a String – Java Code

Write a java program to find first non-repeating character in a string. Given an input string, Write a java code to find first non-repeating character in a string.

For example –

i) Input string – java
Output – j (j is the first non-repeating character in a string)

Subscribe Our Tutorials

Get Latest Updates on Facebook

ii) Input string – web rewrite
Output – b (b is the first non-repeating character in a string)

Anagram Program in Java : Check whether Two Strings are Anagrams of each other

Write a anagram program in java or Java program to check anagram. In this programming question, we are going to write a java code to check whether two strings are anagrams of each other.

Let’s first understand what is an anagram? and how we are going to solve this problem.

What is an Anagram?

Two strings are said to be anagrams of each other if it contains the same characters, only the order of characters in both the strings is different. In other words, both strings must contain the same exact letters in the same exact frequency.

Find Largest Sum Contiguous Subarray – Kadane’s algorithm

Write a program to find largest sum contiguous subarray. Given an array of N elements, find the maximum possible sum of a contiguous subarray. An array can contain both positive and negative values.

For example –

Let’s take an array whose values are { 1, 2, -5, 4, 3, 8 , 5 }

The maximum sum of a subarray in this array is 20.  And the subarray is (4, 3, 8, 5).

Check Prime Number in Java

How to check prime number in Java. In this tutorial, we are going to write a Java program to check whether a number is prime or not. Also In this tutorial, we’ll discuss multiple approaches and their time complexity to solve this problem.

Before writing a program, let’s quickly understand what is a prime number.

What is Prime Number?

A prime number is a number that is greater than 1 and it has no positive divisors other than 1 and itself.

For example – 3, 13, 7  is a prime number, as it’s divisible by 1 and itself. Similarly, 29, 19 etc. are also prime numbers.

6 is not a prime number as it’s divisible by 1, 2, 3 and 6.

 2 is the only even prime number.


How to Check whether a Number is Prime or not in Java

Find Duplicate Elements in an Array – Java Program

Write a java program to find duplicate elements in an array. Given an array of integers, We have to write a code to find all duplicate elements in an array.

For example :

Input : arr = { 2, 5, 3, 1, 8, 7, 5, 3, 2 }

Output: {5, 3, 2}

In this tutorial, I am going to explain three approaches to find duplicate elements in an array. This question is also very important for technical interviews.