-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathThe_art_of_verification.java
More file actions
43 lines (37 loc) · 1.53 KB
/
The_art_of_verification.java
File metadata and controls
43 lines (37 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.util.*;
/*
Cleartrip decided that they wanted to verify the username and password of its users while they were authenticating for a process. One of the code service forms a GET URL which contains the username and password as its parameters. While parsing the URL, the code needs to extract the key-value pairs of ALL the parameters passed in the request URL which may contains '&' or/and '='.
The string can contain any type of alphabetical, numeric and special characters in the URL.
Input format:
A valid Cleartrip link.
Output format:
Print the following:
username: From the URL.
pwd: From the URL.
profile: From the URL.
role: From the URL.
key: From the URL.
Constraints:
1 <= |Length of the URL| <= 100
SAMPLE INPUT
http://www.cleartrip.com/signin/service?username=test&pwd=test&profile=developer&role=ELITE&key=manager
SAMPLE OUTPUT
username: test
pwd: test
profile: developer
role: ELITE
key: manager
URL : https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/the-art-of-verification/
*/
/* Partially Accepted */
class The_art_of_verification {
public static void main(String args[] ) throws Exception {
Scanner sc = new Scanner(System.in);
String inp = sc.nextLine();
String colon_sc = inp.replaceAll("=", ": ");
String removeBeforeQsn = colon_sc.substring(colon_sc.indexOf("?")+1);
removeBeforeQsn.trim();
String removeAmp = removeBeforeQsn.replaceAll("&","\n");
System.out.println(removeAmp);
}
}