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

Описание к видео Cracking The Coding Interview |URLify The Given String | Competitive Programming | Array Problem

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

Комментарии

Информация по комментариям в разработке