Are Two Strings Anagrams
Updated
Problem statement
You are given two strings s and t. Return true if t is an anagram of s, and false otherwise.
t is an anagram of s when it is a rearrangement of the same letters: every letter appears in t exactly as many times as it appears in s. The two strings may have different lengths.
Function
areAnagrams(s: String, t: String) → booleanExamples
Example 1
s = "adobe"t = "abode"return = trueBoth words use one each of a, b, d, e and o, only in a different order. The answer is true.
Example 2
s = "aabbc"t = "abbcc"return = falseBoth strings have 5 letters drawn from a, b and c, but s has two as and one c while t has one a and two cs. The counts differ, so the answer is false.
Example 3
s = "crop"t = "crops"return = falseThe lengths differ (4 and 5), so t has a letter that s lacks. The answer is false.
Constraints
1 <= s.length, t.length <= 2 * 10^4sandtcontain only lowercase English letters
More Adobe Phone Screen questions
- Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
- All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
- Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
- Binary Tree Level-Order Traversal by LevelsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
- Count Occurrences in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
- Count Pairs with Absolute Difference KPHONE SCREEN · Seen Jul 2026
- Count Subsets with Sum KPHONE SCREEN · Seen Jul 2026
- Numbers with Exactly Three DivisorsPHONE SCREEN · Seen Jul 2026
- Sum of Even Nodes on a Path in a Numbered Binary TreePHONE SCREEN · Seen Jul 2026
- Largest Value in Every Sliding WindowPHONE SCREEN · Seen Jul 2026
Similar questions at other companies
- Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
- Portfolio Valuation, Part 1Stripe · PHONE SCREENStripe interview questions
- Summarize Server Healthcheck LogsNVIDIA · PHONE SCREENNVIDIA interview questions
- Convert an Entry List to a MapEPAM · PHONE SCREENEPAM interview questions
- Best Anagram MatchGoogle · PHONE SCREENGoogle interview questions
- Word Frequency in a Large TextRobinhood · PHONE SCREENRobinhood interview questions
- Remove Later Anagrams From a ListBloomberg LP · PHONE SCREENBloomberg LP interview questions
- Employees With Shared InterestsPalantir · PHONE SCREENPalantir interview questions
- Rank Words by FrequencyDatadog · PHONE SCREENDatadog interview questions
- Sort Letters by FrequencyScale AI · PHONE SCREENScale AI interview questions
Interview reports that mention this question
Adobe interview experiences
- Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
- Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
- Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
- Adobe New Grad MTS Interview Questions: 7 Experiences
- Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)