top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

Given 2 strings, a and b, return a string of the form short+long+short in JAVA.. If "hi" and "hello", then "hihellohi"?

+2 votes

Given 2 strings, a and b, return a string of the form shorterString+longerString+shorterString, with the shorter string on the outside and the longer string on the inside. The strings will not be the same length, but they may be empty (length 0). If input is "hi" and "hello", then output will be "hihellohi".

posted Apr 15, 2017 by Prajwal C.m.

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Try this solution :

/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
    public static void main (String[] args) throws java.lang.Exception
        // your code goes here
        Scanner scanner = new Scanner(;
        String a =;
        String b =;
        if(a.length() > b.length())
answer Apr 16, 2017 by Shivam Kumar Pandey
need this code in c language
you can convert yourself.there are lots of tutorials on it using strcat() function.
Similar Questions
+2 votes

Given two strings, append them together (known as "concatenation") and return the result. However, if the concatenation creates a double-char, then omit one of the chars. If the inputs are "Mark" and "Kate" then the output should be "markate". (The output should be in lowercase).

+4 votes

Given a dictionary of strings and another string find out if the string is an exact match to some words in the dictionary or varies at most in only one place of some word of the dictionary?

+2 votes

Return a version of the given string, where for every star (*) in string the star and thr chars immediately to its left and right are gone. So "ab*cd" yields "ad" and "ad**cd" also yields "ad".

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.