Skip to content

GreenRiverCollege-SDEV333/InterviewQuestion1-3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URLify: Write a method to replace all spaces (" ") in a character buffer (array) with "%20". You may assume that the buffer has sufficient space at the end to hold the additional characters, and that you are given the "true" size of the buffer (which is different from the length or capacity of the buffer).

Constraint: perform the operation in place (in the existing buffer), without creating a new or temporary buffer or string.

Example

            buffer                             size
            -------------------------------    ----
 Input      Hello, world!                      13
 Output     Hello,%20world!                    15

 Input      Dr Martin Luther King              21
 Output     Dr%20Martin%20Luther%20King        27

Learning Objectives:

  • To practice an interview question.
  • To recognize the difference between size and length when working with a buffer (similar to how a resizable ArrayList, and/or a StringBuilder's internals would work).
  • To create and implement an algorithm to manipulate contents of an array.
  • To analyze the runtime performance of the algorithm.

Source: Gayle Laakmann McDowell. 2016. Cracking the Coding Interview (6th ed.) CareerCup, Palo Alto, CA.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages