How check whether a number is prime or not in java.
Given an input integer, write a code to check whether an input number is prime or not.
For example –
Example 1:
Input: 7
output: true
Example 2:
Input: 12
Output: false
Given two strings, write a code to check whether two strings are anagram of each other or not. In this tutorial, I am going to discuss multiple approaches and their java implementation to check if two strings are anagrams or not.
Let’s first understand what is an anagram? and how we are going to solve this problem.
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.