Friday, 2 December 2016

Write a program to check wether the given number is anagram or not?

Lot of people facing programming problem in every Software Job interview. Now a days, one programming question is always asking by interviwer is "Write a program to check wether the given number is anagram or not?". So today we are here to solve to problem in this blog. Let me first take the defination of Anagram Number that is taken from google and this is the best defination that anyone can easily understand.

An anagram is direct word switch or word play, the result of rearranging the letters of a word or phrase to produce a new word or phrase, using all the original letters exactly once; for example, the word anagram can be rearranged into nag-a-ram. Someone who creates anagrams may be called an "anagrammatist".

Write a program to check wethere the given number is anagram or not?

import java.util.*;
class AnagramNumber
 public static void main(String[] args)
  int n1=12345;
  int n2=43251;

  String s1=String.valueOf(n1);
  String s2=String.valueOf(n2);

  char[] ch1=s1.toCharArray();
  char[] ch2=s2.toCharArray();

  boolean flag=false;
  for(int i=0;i<ch1.length;i++){


   System.out.println("anagram number");
   System.out.println("not anagram number");

Keep visiting for more programs....Happy Coding....

Thank you(SmartiesGeeks)

1 comment: