Problem · Array

Match Consecutive Word Boundaries

Learn this problem
EasyCapital OneINTERNOA

Problem statement

Given an array of strings words, examine every consecutive pair of words.

Return a boolean array of length words.length - 1. Its ith value is true exactly when words[i] and words[i + 1] start with the same character and end with the same character. Otherwise, it is false.

Function

matchConsecutiveWordBoundaries(words: String[]) → boolean[]

Examples

Example 1

words = ["abcd","abdd","da","dd"]return = [true,false,false]

The first pair starts with a and ends with d in both words, so its result is true. The second pair starts with different characters, and the third pair ends with different characters.

Example 2

words = ["a","a"]return = [true]

The only pair has the same first and last character.

Constraints

  • 1 <= words.length <= 100
  • 1 <= words[i].length <= 100
  • Every word contains only lowercase English letters.

More Capital One problems

drafts saved locally
public boolean[] matchConsecutiveWordBoundaries(String[] words) {
    // write your code here
}
words["abcd","abdd","da","dd"]
expected[true,false,false]
checking account