Problem Statement
????
When a web client (like a browser) requests a particular web page, it typically replaces certain characters with escape sequences. For instance, spaces are replaced with “%20″. Your task is to reverse this, replacing every escape sequence in the input with the character it represents. Each escape sequence is formatted as “%XX” where XX is the ASCII value of the escaped character in hexadecimal.
Definition
????
Class:
URLParser
Method:
parse
Parameters:
String
Returns:
String
Method signature:
String parse(String url)
(be sure your method is public)
????
Constraints
-
url will contain between 1 and 50 characters, inclusive.
-
Each ‘%’ in the input will be followed by a hexadecimal value between 20 (hex) and 7E (letters will be uppercase).
-
Each character in the input will have ASCII value between 32 and 126, inclusive.
Examples
0)
????
“http://www.%20%40%20%40%20.com/%25“
Returns: “http://www. @ @ .com/%”
“%20″ is the escape sequence for ‘ ‘, while “%40″ stands for ‘@’ and “%25″ stands for ‘%’.
1)
????
“%20%21%22%23%24%25%26%27%28″
Returns: ” !\”#$%&’(“
2)
????
“%48%65%6C%6C%6F%20%57%6F%72%6C%64%21″
Returns: “Hello World!”
3)
????
“%2525″
Returns: “%25″
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.
>> 本文固定链接: http://www.vcgood.com/archives/147