Updating exercises

This commit is contained in:
Carlos
2025-07-14 10:09:13 -04:00
parent 57956bf728
commit 7f1381ae93
25 changed files with 634 additions and 13 deletions

View File

@@ -0,0 +1,31 @@
// @leet start
/**
* Encodes a list of strings to a single string.
*
* @param {string[]} strs
* @return {string}
*/
var key = '$#@C$(){(($[]%^[$()${#${(}'
var encode = function(strs) {
if (strs.length === 0) return [];
const encoded = strs.join(key);
return encoded;
};
/**
* Decodes a single string to a list of strings.
*
* @param {string} s
* @return {string[]}
*/
var decode = function(str) {
if (Array.isArray(str)) return str;
let decoded = str.split(key);
return decoded;
};
/**
* Your functions will be called as such:
* decode(encode(strs));
*/
// @leet end