Skip to main content

Posts

Showing posts with the label Java Substring Comparisons Hackerrank Solution

Java Substring Comparisons Hackerrank Solution

 Java Substring Comparisons Hackerrank Solution For Explanation Watch Video: Sample Input 0 welcometojava 3 Sample Output 0 ava wel Code: import  java.util.Scanner; public   class  Solution {      public   static  String getSmallestAndLargest(String s,  int  k) {         String smallest =  "" ;         String largest =  "" ;          smallest = s.substring(0,k);         largest = s.substring(0,k);         for(int i=0;i<=s.length()-k;i++){             String sub = s.substring(i,i+k);             if(smallest.compareTo(sub...