Merge Strings Alternately - LeetCode 1768 - Python Solution

Publié le: 18 avril 2023
sur la chaîne: Code with Carter
2,306
29

Solution Blog (sign into leetcode to view):
https://leetcode.com/problems/merge-s...

Just zip them together and combine each iteration.

Take the difference and slice the longer word by that difference.

Where M is length of word1, and N is length of word2

Time complexity: O(M + N)
Space complexity: O(M + N)

You can also use zip_longest to handle the longer word and make the fillvalue '''

Hope this helped - have an awesome day!
#python #leetcode #tutorial


Sur cette page du site, vous pouvez voir la vidéo en ligne Merge Strings Alternately - LeetCode 1768 - Python Solution durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Code with Carter 18 avril 2023, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 2,306 fois et il a aimé 29 téléspectateurs. Bon visionnage!