Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions src/CheckIfTwoStringArraysAreEquivalent1662.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Tags: Array, String
package com.leetcode.easy;

public class CheckIfTwoStringArraysAreEquivalent1662 {
/*
Let N be the maximum of the number of all characters in word1 and the number of all characters in word2.
Time complexity: O(N), since we need to iterate over all characters in word1 and word2 to build the new strings.
Space complexity: O(N), since we need extra O(N) space to store the new built strings.
*/
public boolean arrayStringsAreEqual(String[] word1, String[] word2) {
return String.join("", word1).equals(String.join("", word2));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.leetcode.easy;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class CheckIfTwoStringArraysAreEquivalent1662Test {
private CheckIfTwoStringArraysAreEquivalent1662 solution;

@BeforeEach
void setUp() {
solution = new CheckIfTwoStringArraysAreEquivalent1662();
}

@Test
void testArrayStringsAreEqual_Example1() {
String[] word1 = {"ab", "c"};
String[] word2 = {"a", "bc"};

boolean result = solution.arrayStringsAreEqual(word1, word2);

assertTrue(result);
}

@Test
void testArrayStringsAreEqual_Example2() {
String[] word1 = {"a", "cb"};
String[] word2 = {"ab", "c"};

boolean result = solution.arrayStringsAreEqual(word1, word2);

assertFalse(result);
}

@Test
void testArrayStringsAreEqual_Example3() {
String[] word1 = {"abc", "d", "defg"};
String[] word2 = {"abcddefg"};

boolean result = solution.arrayStringsAreEqual(word1, word2);

assertTrue(result);
}
}