Column Right

Breaking News

Hacker Rank | Java Strings Introduction


Given two strings of lowercase English letters,  and , perform the following operations:

  1. Sum the lengths of  and .
  2. Determine if  is lexicographically larger than  (i.e.: does  come before  in the dictionary?).
  3. Capitalize the first letter in  and  and print them on a single line, separated by a space.


import java.util.*;

public class Solution {

    public static void main(String[] args) {
        Scanner sc=new Scanner(;
        /* Sum of lengths of two strings */
        int l = A.length()+B.length();

/*Determine if  is lexicographic-ally larger than  (i.e.: does  come before  in the dictionary?)*/
            for(int i=0;i<A.length();i++)
                char x,y;
            int a =x,b=y;

            //Changing first letter to Upper Case i.e Making First letter capital
            System.out.println(A.substring(01).toUpperCase() + A.substring(1) + 
            " "+ B.substring(01).toUpperCase() + B.substring(1));

No comments