6 kyu
Consecutive strings
24,803 of 83,348g964
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 | 241910 |
Total Skips | 55966 |
Total Code Submissions | 523818 |
Total Times Completed | 83348 |
Ruby Completions | 2513 |
Python Completions | 27801 |
JavaScript Completions | 24803 |
CoffeeScript Completions | 32 |
Haskell Completions | 726 |
Clojure Completions | 222 |
C# Completions | 4797 |
Java Completions | 8784 |
Elixir Completions | 321 |
C++ Completions | 3485 |
PHP Completions | 2008 |
TypeScript Completions | 1915 |
Crystal Completions | 31 |
F# Completions | 99 |
C Completions | 1081 |
OCaml Completions | 52 |
Rust Completions | 1239 |
Swift Completions | 648 |
Go Completions | 1934 |
R Completions | 167 |
Shell Completions | 91 |
Kotlin Completions | 830 |
PowerShell Completions | 80 |
Julia Completions | 81 |
Scala Completions | 299 |
Nim Completions | 18 |
Reason Completions | 4 |
Racket Completions | 41 |
Dart Completions | 555 |
Haxe Completions | 14 |
Pascal Completions | 12 |
Raku Completions | 8 |
Lua Completions | 130 |
Perl Completions | 26 |
Elm Completions | 9 |
COBOL Completions | 8 |
D Completions | 8 |
Erlang Completions | 12 |
Prolog Completions | 9 |
Total Stars | 3563 |
% of votes with a positive feedback rating | 85% of 8320 |
Total "Very Satisfied" Votes | 6275 |
Total "Somewhat Satisfied" Votes | 1658 |
Total "Not Satisfied" Votes | 387 |