Diwali Offer!Flat 20% OFF
Enroll Now
PrakalpanaLive online tech training

43. Valid Anagram

EasyDay 14 of 60Strings

Given two strings s and t, return true if t is an anagram of s, meaning it uses exactly the same letters the same number of times, possibly in a different order. Otherwise return false.

Example 1
Input: s = "anagram", t = "nagaram"
Output: true
Example 2
Input: s = "rat", t = "car"
Output: false
s has a t that t does not, and t has a c that s does not.
Constraints
  • 1 <= s.length, t.length <= 5 * 10^4
  • Both strings contain only lowercase English letters
Hints
Frequently asked at: Amazon, Bloomberg, Microsoft, TCS, Accenture
Ctrl + Enter runs the examples

Not sure what to learn next?

A 1-on-1 session with an industry mentor and a roadmap built for you. How it works

  1. 1Discuss your goals
  2. 2Get a personal plan
  3. 3Start learning
Book for β‚Ή200/ 30 min