Write code to determine if two words are anagrams.

AnswerBot
2y

Code to check if two words are anagrams

  • Convert both words to lowercase

  • Remove all spaces and punctuation

  • Sort the characters in both words

  • Compare the sorted words

Anonymous
1y

import string

class AnagramChecker:

def init(self, word1, word2):

self.word1 = word1

self.word2 = word2

def preprocessword(self, word):

word = word.lower()

word = word.translate(str.maketrans('', '',...read more

Sharath Krishana
1y

def are_anagrams(word1, word2):

word1 = word1.replace(" ", "").lower()

word2 = word2.replace(" ", "").lower()

if len(word1) != len(word2):

return False

char_freq1 = {}

char_freq2 = {}

for char in word...read more

Amitabh Soni
1y
public boolean isAnagram(String s, String t) { char[] sortedS = Arrays.sort(s.toCharArray()); char[] sortedT = Arrays.sort(t.toCharArray()); return Arrays.equals(sortedS, sortedT); }
HARSHA
1y

ArrayList<Character> ee=new ArrayList<Character>(String);

for(int i=0;i<s1.length();i++)

{

ee.add(s1.charAt(i));

}

int c=0;

for(int i=0;i<s2.length();i++)

{

if(ee.contains(s2.charAt(i))

{

c++;

}}

if(c==s1.length(...read more

Select
Add answer anonymously...

KPIT Technologies Senior Software Engineer interview questions & answers

A Senior Software Engineer was asked 3mo agoQ. Explain structures in C++.
A Senior Software Engineer was asked 4mo agoQ. Explain an efficient sorting algorithm.
A Senior Software Engineer was asked 4mo agoQ. Explain the STL features in C++.

Popular interview questions of Senior Software Engineer

A Senior Software Engineer was asked 3mo agoQ1. Explain structures in C++.
A Senior Software Engineer was asked 4mo agoQ2. Explain an efficient sorting algorithm.
A Senior Software Engineer was asked 4mo agoQ3. Explain the STL features in C++.
KPIT Technologies Senior Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits