Tap here to switch tabs
Problem
Submissions

Problem: Maximum Distance Between Unequal Words in Array I

Maximum Distance Between Unequal Words in Array I asks you to choose two positions containing different strings and return the largest inclusive span between them, or zero if all strings match.

Statement

You are given an array of strings words.

The distance between two indices i and j (where i ≤\leq j) is defined as j −- i ++ 11.

Return the maximum distance between two indices i and j such that words[i] ≠\neq words[j]. If no two unequal words exist, return 00.

Constraints:

  • 1≤1 \leq words.length ≤100\leq 100

  • 1≤1 \leq words[i].length ≤10\leq 10

  • words[i] consists of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Distance Between Unequal Words in Array I

Maximum Distance Between Unequal Words in Array I asks you to choose two positions containing different strings and return the largest inclusive span between them, or zero if all strings match.

Statement

You are given an array of strings words.

The distance between two indices i and j (where i ≤\leq j) is defined as j −- i ++ 11.

Return the maximum distance between two indices i and j such that words[i] ≠\neq words[j]. If no two unequal words exist, return 00.

Constraints:

  • 1≤1 \leq words.length ≤100\leq 100

  • 1≤1 \leq words[i].length ≤10\leq 10

  • words[i] consists of lowercase English letters.