Skip to content

All Longest Strings

EasyPython 3ArraysStrings

You are given an array of strings input_array. Return an array containing all of its longest strings — every string whose length equals the maximum string length in the array — keeping their original relative order.

Constraints:
  - 1 <= len(input_array) <= 10
  - 1 <= len(input_array[i]) <= 10
  - the array contains at least one string
Examples:
  ["aba", "aa", "ad", "vcd", "aba"]  -> ["aba", "vcd", "aba"]
    (max length is 3; "aba", "vcd", "aba" all have length 3, in order)
  ["abc", "eeee", "abcd", "dcd"]     -> ["eeee", "abcd"]
    (max length is 4)
  ["a", "abc", "cba"]                -> ["abc", "cba"]
  ["enn", "b"]                       -> ["enn"]

Python 3, run in your browser. Run tests runs the problem's own tests with a free account; the AI interviewer reads your code and your runs in a practice interview.

Loading the editor…