From 3596a4d3abdcc44b6b9f5f556d58df5df94a07a9 Mon Sep 17 00:00:00 2001 From: vivek sharma <45270024+vvksharrma@users.noreply.github.com> Date: Sun, 24 Oct 2021 17:48:14 +0530 Subject: [PATCH] Create akgString Given 2 strings, a and b, return a string of the form short+long+short, with the shorter string on the outside --- Java Basic Program/akgString | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Java Basic Program/akgString diff --git a/Java Basic Program/akgString b/Java Basic Program/akgString new file mode 100644 index 0000000..c64f255 --- /dev/null +++ b/Java Basic Program/akgString @@ -0,0 +1,18 @@ + +class main { + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + String str1 = in.nextLine(); + String str2 = in.nextLine(); + System.out.println(shortLongShort(str1, str2)); + } + + static String shortLongShort(String a, String b) { + int l1 = a.length(), l2 = b.length(); + + if(l1 < l2) + return a + b + a; + else + return b + a + b; + } +}