FastPrepCheck If Two String Arrays Are Equivalent

Check If Two String Arrays Are Equivalent

Microsoft logoMicrosoft● EasyFULLTIMEONSITE INTERVIEW
Learn

Problem statement

You are given two arrays of non-empty string fragments, word1 and word2.

Concatenate the fragments in each array in order. Return true when the two resulting strings are exactly equal, and return false otherwise.

Comparison is case-sensitive.

Function

arrayStringsAreEqual(word1: String[], word2: String[]) → boolean

Examples

Example 1

word1 = ["Mic","ro","soft"]word2 = ["M","ic","roso","ft"]return = true

Both arrays concatenate to Microsoft.

Example 2

word1 = ["ab","c"]word2 = ["a","bc"]return = true

The fragment boundaries differ, but both arrays form abc.

Example 3

word1 = ["a","cb"]word2 = ["ab","c"]return = false

The arrays form acb and abc, which differ.

Constraints

  • 1 <= word1.length, word2.length <= 1000
  • Every fragment contains from 1 through 1000 letters.
  • The total number of characters in each array is at most 100000.
  • Comparison is case-sensitive.

More Microsoft problems

See Microsoft hiring insights
public boolean arrayStringsAreEqual(String[] word1, String[] word2) {
    // Write your code here.
}
word1["Mic","ro","soft"]
word2["M","ic","roso","ft"]
expectedtrue
Checking account…