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

Stats:

CreatedJan 25, 2016
PublishedJan 25, 2016
Warriors Trained241910
Total Skips55966
Total Code Submissions523818
Total Times Completed83348
Ruby Completions2513
Python Completions27801
JavaScript Completions24803
CoffeeScript Completions32
Haskell Completions726
Clojure Completions222
C# Completions4797
Java Completions8784
Elixir Completions321
C++ Completions3485
PHP Completions2008
TypeScript Completions1915
Crystal Completions31
F# Completions99
C Completions1081
OCaml Completions52
Rust Completions1239
Swift Completions648
Go Completions1934
R Completions167
Shell Completions91
Kotlin Completions830
PowerShell Completions80
Julia Completions81
Scala Completions299
Nim Completions18
Reason Completions4
Racket Completions41
Dart Completions555
Haxe Completions14
Pascal Completions12
Raku Completions8
Lua Completions130
Perl Completions26
Elm Completions9
COBOL Completions8
D Completions8
Erlang Completions12
Prolog Completions9
Total Stars3563
% of votes with a positive feedback rating85% of 8320
Total "Very Satisfied" Votes6275
Total "Somewhat Satisfied" Votes1658
Total "Not Satisfied" Votes387
Ad
Contributors
  • g964 Avatar
  • myjinxin2015 Avatar
  • cacr Avatar
  • Chrono79 Avatar
  • kazk Avatar
  • Blind4Basics Avatar
  • monadius Avatar
  • hobovsky Avatar
  • solitude Avatar
  • trashy_incel Avatar
  • looplopp Avatar
  • user8436785 Avatar
  • akar-0 Avatar
  • Glinator Avatar
  • Just4FunCoder Avatar
  • KayleighWasTaken Avatar
  • saudiGuy Avatar
Ad