6 kyu
Consecutive strings
24,593 of 82,622g964
Description:
You are given an array(list) strarr
of strings and an integer k
. Your task is to return the first longest string
consisting of k consecutive strings taken in the array.
Examples:
strarr = ["tree", "foling", "trashy", "blue", "abcdef", "uvwxyz"], k = 2
Concatenate the consecutive strings of strarr by 2, we get:
treefoling (length 10) concatenation of strarr[0] and strarr[1]
folingtrashy (" 12) concatenation of strarr[1] and strarr[2]
trashyblue (" 10) concatenation of strarr[2] and strarr[3]
blueabcdef (" 10) concatenation of strarr[3] and strarr[4]
abcdefuvwxyz (" 12) concatenation of strarr[4] and strarr[5]
Two strings are the longest: "folingtrashy" and "abcdefuvwxyz".
The first that came is "folingtrashy" so
longest_consec(strarr, 2) should return "folingtrashy".
In the same way:
longest_consec(["zone", "abigail", "theta", "form", "libe", "zas", "theta", "abigail"], 2) --> "abigailtheta"
n being the length of the string array, if n = 0
or k > n
or k <= 0
return "" (return Nothing
in Elm, "nothing" in Erlang).
Note
consecutive strings : follow one after another without an interruption
Fundamentals
Similar Kata:
Stats:
Created | Jan 25, 2016 |
Published | Jan 25, 2016 |
Warriors Trained | 240603 |
Total Skips | 55785 |
Total Code Submissions | 521163 |
Total Times Completed | 82622 |
Ruby Completions | 2508 |
Python Completions | 27500 |
JavaScript Completions | 24593 |
CoffeeScript Completions | 32 |
Haskell Completions | 722 |
Clojure Completions | 221 |
C# Completions | 4768 |
Java Completions | 8737 |
Elixir Completions | 321 |
C++ Completions | 3450 |
PHP Completions | 1999 |
TypeScript Completions | 1893 |
Crystal Completions | 31 |
F# Completions | 99 |
C Completions | 1077 |
OCaml Completions | 51 |
Rust Completions | 1225 |
Swift Completions | 644 |
Go Completions | 1907 |
R Completions | 166 |
Shell Completions | 90 |
Kotlin Completions | 823 |
PowerShell Completions | 78 |
Julia Completions | 81 |
Scala Completions | 297 |
Nim Completions | 18 |
Reason Completions | 4 |
Racket Completions | 41 |
Dart Completions | 535 |
Haxe Completions | 14 |
Pascal Completions | 12 |
Raku Completions | 7 |
Lua Completions | 129 |
Perl Completions | 24 |
Elm Completions | 9 |
COBOL Completions | 8 |
D Completions | 8 |
Erlang Completions | 11 |
Prolog Completions | 9 |
Total Stars | 3545 |
% of votes with a positive feedback rating | 85% of 8301 |
Total "Very Satisfied" Votes | 6261 |
Total "Somewhat Satisfied" Votes | 1653 |
Total "Not Satisfied" Votes | 387 |