Find Duplicate Characters in a String | Java Code

Given an input string, Write a java code to find duplicate characters in a String.

For example :

Example 1:

Input    : “Java”
Output : a

The character a appears more than once in a string.

Example 2:

Input : “programming”
Output : m,g,r

These three characters (m, g, r) appears more than once in a string.

How to Calculate Power using Recursion | Pow(x, n)

In this tutorial, I am going to discuss how to calculate power using recursion.

Problem statement – Write a code to implement function pow(x, n), which calculates x raised to the power n (i.e. x^n). In this problem, We don’t have to use in-built function Math.pow.

For example:

Example 1:

Input:   x = 2.00000,    n = 3
Output:  8

Example 2:

Input: x = 2.10000,     n = 3
Output: 9.26100

Example 3:

Input: x = 2.00000,   n = -2
Output: 0.25000