FastPrepIsomorphic Strings
Problems/Isomorphic Strings

Isomorphic Strings

Google logoGoogle● EasyNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asks whether str1 maps to str2, and gives abc→XYZ as true and aaa→XYZ as false. We use the standard one-to-one mapping rule. The open follow-up about mergeable mappings stays separate. Our version is about 96% the same as the reported question.

Given two strings first and second, return true when characters of first can be replaced to obtain second.

Every occurrence of one source character must map to the same target character, and two different source characters may not map to the same target character. Character order is preserved.

Function

areIsomorphic(first: String, second: String) → boolean

Examples

Example 1

first = "egg"second = "add"return = true

e maps to a and g maps to d.

Example 2

first = "foo"second = "bar"return = false

o would need to map to both a and r.

Example 3

first = "aaa"second = "XYZ"return = false

The same source character cannot map to three targets.

Constraints

  • 0 <= first.length, second.length <= 200000.
  • Strings contain ASCII characters.

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Non-Repeating CharacterAutodesk · ONSITE INTERVIEWAutodesk interview questions
  • Container Ledger with TradesFlexport · ONSITE INTERVIEWFlexport interview questions
  • Count Adjacent Symbol Pairs for BPEAmazon · ONSITE INTERVIEW
  • Count a User's Actions in an Event LogMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Map and Accumulate Learning QueriesPalantir · ONSITE INTERVIEWPalantir interview questions
  • Filter Pins by Excluded IDsPinterest · ONSITE INTERVIEWPinterest interview questions
  • First Non-Repeating CharacterGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
  • Minimum Replacements to Make Two Strings AnagramsBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Logger Rate LimiterAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
  • Isomorphic StringsRemitly · ONSITE INTERVIEWRemitly interview questions

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public boolean areIsomorphic(String first, String second) {
        // Write your code here.
    }
}
Checking account…