-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsecutive strings.js
More file actions
34 lines (27 loc) · 933 Bytes
/
Copy pathConsecutive strings.js
File metadata and controls
34 lines (27 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* You are given an array 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.
Example:
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 "".
Note
consecutive strings : follow one after another without an interruption */
function longestConsec(strarr, k) {}
console.log(
longestConsec(
['zone', 'abigail', 'theta', 'form', 'libe', 'zas', 'theta', 'abigail'],
2
)
)
// console.log(
// longestConsec(
// [
// 'ejjjjmmtthh',
// 'zxxuueeg',
// 'aanlljrrrxx',
// 'dqqqaaabbb',
// 'oocccffuucccjjjkkkjyyyeehh',
// ],
// 1
// )
// )
// console.log(longestConsec([], 3))
// console.log(longestConsec(['it', 'wkppv', 'ixoyx', '3452', 'zzzzzzzzzzzz'], 3))