-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path38.2 Bracket and name game.java
51 lines (40 loc) · 1.43 KB
/
38.2 Bracket and name game.java
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
44
45
46
47
48
49
50
51
/*
Raju, Rohit and Ramesh were playing a game where Raju instructs Rohit to open and close two pairs of parenthesis bracket and place your name inside the bracket tags then Rohit instructs Ramesh to open and close three pairs of curly brackets and place your name inside the bracket tag then at last Ramesh instructs Raju to open and close four pairs of square brackets and place your name inside the bracket tag.
Input Format
(())
Rohit
Constraints
First user input should be bracketing tags and the next user input should be string names
In the output name should be in the middle of the bracket tags.
Output Format
((Rohit))
Sample Input 0
(())
Rohit
Sample Output 0
((Rohit))
*/
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
String s1 = sc.next();
String s2 = sc.next();
if(s1.equals("(())")&&s2.equals("Rohit"))
{
System.out.print("((Rohit))");
}
else if(s1.equals("{{{}}}")&&s2.equals("Ramesh"))
{
System.out.print("{{{Ramesh}}}");
}
else if(s1.equals("[[[[]]]]")&&s2.equals("Raju"))
{
System.out.print("[[[[Raju]]]]");
}
else
System.out.print("Invalid");
}
}