From 050d2f4041551058f4aa228d7ea3a181bfd48415 Mon Sep 17 00:00:00 2001 From: ImAlpha Date: Thu, 24 Aug 2023 23:53:58 -0700 Subject: [PATCH] added for loop method to encode and decode --- .../Arrays_and_Hashing/Encode_Decode_Strings.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/NeetCodeRoadmap/Arrays_and_Hashing/Encode_Decode_Strings.py b/NeetCodeRoadmap/Arrays_and_Hashing/Encode_Decode_Strings.py index e4c3aec..bfd72da 100644 --- a/NeetCodeRoadmap/Arrays_and_Hashing/Encode_Decode_Strings.py +++ b/NeetCodeRoadmap/Arrays_and_Hashing/Encode_Decode_Strings.py @@ -1,9 +1,14 @@ -def encode(self, strs): +def encode(strs): # write your code here + key = [] + encode = [] + for x in strs: + if x in key: + encode.append(x) """ @param: str: A string @return: decodes a single string to a list of strings """ -def decode(self, str): +def decode(str): # write your code here \ No newline at end of file