It is possible to use any

number of characters '/' as a delimiter in path instead of one traditional '/'. For

example,

strings //usr///local//nginx/sbin// and /usr/local/nginx///sbi

n are equivalent. The character '/' (or some sequence of such characters) at the

end of the path is required only in case of the path to the root directory, which can be

represented as single character '/'.

A path called normalized if it contains the smallest possible number of

characters '/'.

Your task is to transform a given path to the normalized form.
Sample Input

//usr///local//nginx/sbin

Sample Output

/usr/local/nginx/sbin

Recommended Answers

All 4 Replies

We don't do your assignments for you - read the stickies at the top of the forum.

Write some code, if you have questions, post the code, be direct in what you're having problems with.

It is possible to use any number of characters '/' as a delimiter in path instead of one traditional '/'. FIt is possible to use any

No. When in doubt test it in a command prompt. MS-Windows accepts only a single / character immediately before each folder name.

AD - you're being too M$-centric.

DOS/Windows use backslash - \

The OP refers to forward slashes / or // or ///, which in Unix/Linux are treated as single slash, so the Google tells me.

AD - you're being too M$-centric.

LOL You're right :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.