Skip to main content

Command Palette

Search for a command to run...

Check If Two String Arrays are Equivalent

Published
1 min read
Check If Two String Arrays are Equivalent
G

As a Systems Engineer at Tata Consultancy Services, I deliver exceptional software products for mobile and web platforms, using agile methodologies and robust quality maintenance. I am experienced in performance testing, automation testing, API testing, and manual testing, with various tools and technologies such as Jmeter, Azure LoadTest, Selenium, Java, OOPS, Maven, TestNG, and Postman.

I have successfully developed and executed detailed test plans, test cases, and scripts for Android and web applications, ensuring high-quality standards and user satisfaction. I have also demonstrated my proficiency in manual REST API testing with Postman, as well as in end-to-end performance and automation testing using Jmeter and selenium with Java, TestNG and Maven. Additionally, I have utilized Azure DevOps for bug tracking and issue management.

Given two string arrays word1 and word2, return true if the two arrays represent the same string, and false otherwise.

A string is represented by an array if the array elements concatenated in order forms the string.

LeetCode Problem - 1662

class Solution {
    public boolean arrayStringsAreEqual(String[] word1, String[] word2) {
        // Initialize two StringBuilder objects to concatenate strings from word1 and word2
        StringBuilder str1 = new StringBuilder();
        StringBuilder str2 = new StringBuilder();

        // Concatenate strings from word1 into str1
        for (String string : word1) {
            str1.append(string);
        }
        // Concatenate strings from word2 into str2
        for (String string : word2) {
            str2.append(string);
        }

        // Check if the concatenated strings from word1 and word2 are equal
        return str1.toString().contentEquals(str2);
    }
}

More from this blog

S

Software and Performance Testing Insights

462 posts

Results-Driven Agile QA Specialist | Expert in Mobile & Web Testing | Proficient in Test Planning, Execution, and Root Cause Analysis.