## Find the First Non-repeated Character in a String – Java Code

Write a java program to find the first non-repeated character in a string.Given an input string, we have to write a java code to find the first non-repeated character in a string.

For example –

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

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

## Java program to check anagram : Check whether Two Strings are Anagrams of each other

Write a 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.

## How to Check if a Number is a Power of 2

How to check if a number is a power of 2.  To understand this question, let’s take some example.

Example –

Input – 16   – 16 is a power of 2 (2^4).

Input – 15 – 15 is not a power of 2.

Input – 32- 32 is a power of 2 (2^5).

We can use multiple approaches to check whether a number is a power of 2 or not.

## Reverse a String in PHP without using strrev() Method

Write a script to reverse a string in PHP without using strrev() method. In PHP, we can reverse a string easily using strrev() method. But think how will you reverse a string without using an inbuilt strrev() method.

## Find Maximum Subarray Sum in an Array – Kadane’s algorithm

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

## Recursion vs Iteration – Difference between Recursion and Iteration

Recursion vs Iteration. What’s the difference between recursion and iteration. Recursion and Iteration both are two different programming approaches. In some cases recursion is best suited and in some other cases iterative way of programming is good.

In programming, repeated set of instructions can be handled either by using recursive or iterative approach in your code. So which approach you choose and why. Let’s talk about recursion vs iteration.

## Queue Data Structure Implementation Using an Array

Write a program to implement a queue using an array.  In this tutorial, You are going to learn about Queue data structure and their implementation using an array in C, C++ & Java. In my previous posts, I have explained Stack and Linked List data structure.

## Queue Data Structure

In Queue data structure, An element is inserted at one end called rear and deleted at other end called front. As compared to stack data structure in which insertion and deletion are allowed only at one end. Queue data structure is also called FIFO (First In First out).

## Implementation of Stack in PHP

Stack is a very important data structure in computer science, It works on the principle of last-in-first-out (LIFO ). The element which inserted last is the first element to be popped. In this tutorial, You will learn about stack data structure and how to implement a stack in PHP.

## Java Program to Check Prime Number

Write a Java program to check prime number. Given an input integer, We have to write an efficient code to check whether a number is prime or not.

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

### 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.