Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 2.17 KB

File metadata and controls

27 lines (20 loc) · 2.17 KB

String encode and decode medium #javascript #blind75

by Pawan Kumar @jsartisan

Take the Challenge

Create a function that can convert an array of strings into a single encoded string, and another function that can decode that string back into the original array of strings. The encoding and decoding should be reversible, meaning decoding the encoded string should give back the exact same array that was encoded.

Constraints:

  • 0 ≤ strs.length < 100
  • 0 ≤ strs[i].length < 200
  • strs[i] contains only UTF-8 characters

Examples:

// Example 1:
const input1 = ["neet", "code", "love", "you"];
const encoded1 = encode(input1);
console.log(decode(encoded1)); 
// Output: ["neet", "code", "love", "you"]

// Example 2:
const input2 = ["we", "say", ":", "yes"];
const encoded2 = encode(input2);
console.log(decode(encoded2));
// Output: ["we", "say", ":", "yes"]

Back Share your Solutions Check out Solutions