Marks :10
: 0 | : 0
You are given a string $$$S$$$ representing a variable name in either C++ or Java as per the following rules :
Note : Assume that a Java variable name never contains '_' before any alphabet. In other words, if the given variable name contains '_' before any alphabet, treat the given variable name as a C++ variable name and vice versa.
Your task is to convert a C++ variable name into a Java variable name and vice versa.
The first line of input contains an integer $$$t \hspace{2 pt}(1 \le t \le 10^4)$$$ — the number of testcases. The description of $$$t$$$ testcases follows.
The first line of each testcase contains an integer $$$n \hspace{2 pt} (1 \le n \le 10^5)$$$ — the length of string $$$S$$$.
The second line of each testcase contains a string of length $$$n$$$ denoting the variable name in either C++ or Java.
The strings consist of lowercase and uppercase latin letters and underscores '_' and it is guaranteed that the sum of lengths of strings over all testcases does not exceed $$$10^5$$$.
For each testcase, print the converted variable name in a single line.
215thisIsAVariable18this_is_a_variable
this_is_a_variable thisIsAVariable
In sample testcase 1, the given string is a Java variable name and hence we convert it into C++ variable name separating the words with underscores.
In sample testcase 2, the given string is a C++ variable name and hence we convert it into Java variable name by using camelCase notation. Note that "ThisIsAVariable" is not a valid Java variable name.
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.