Title (100 Marks)
Input Format
You will be given a function with string as single argument.Constraints
1 <= |S| <= 10^4Output Format
You need to return the String either "True" or "False".Sample TestCase 1
Input
This Is String Example
Output
True
- Solution:
- import java.io.*;
public class CandidateCode {
public static void main(String args[] ) throws Exception {
Scanner sc = new Scanner(System.in);
String s1 = sc.nextLine();
StringBuffer s2 = new StringBuffer();
String arr[] = s1.split(" ");
for(int i=0; i<arr.length; i++)
{
s2.append(arr[i].substring(0,1).toUpperCase() + arr[i].substring(1)+" ");
}
String str = s2.toString();
if(s1.equals(str.trim()))
System.out.print("True");
else
System.out.print("False");
}
}
No comments:
Post a Comment