Cracking The Coding Interview |URLify The Given String | Competitive Programming | Array Problem

Publié le: 26 septembre 2020
sur la chaîne: Pawan S Nair
5,113
108

This question is mostly asked in a product based company to check the concept of string, and in this video, we will see how can we solve it.

A common approach in string manipulation problems is to edit the string starting from the end and working backwards. This is useful because we have an extra buffer at the end, which allows us to change the character without worrying about what we're overwriting.
We will use this approach to this problem. The algorithm employs a two scan approach. In this first scan, we count the number of spaces. By tripling this number, we can compute how many extra characters we will have in the final string. In the second pass, which is done in reverse order, we actually edit the string. When we see a space, we replace t with %20. If there is no space then we copy the original character


Sur cette page du site, vous pouvez voir la vidéo en ligne Cracking The Coding Interview |URLify The Given String | Competitive Programming | Array Problem durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Pawan S Nair 26 septembre 2020, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 5,113 fois et il a aimé 108 téléspectateurs. Bon visionnage!