We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int l= c.length();
char minchar=Character.MAX_VALUE;
int sum1=0;
int sum2=0;
for(int j=0;j<=l-k;j++){
if(c.charAt(j)<=minchar){
minchar=c.charAt(j);
sum2=j;
}
}System.out.println(c.substring(sum2,sum2+k));
char maxchar= minchar;
for(int i=0;i<=l-k;i++){
if(c.charAt(i)>=maxchar){
maxchar=c.charAt(i);
sum1=i;
}
}System.out.println(c.substring(sum1,sum1+k));Can somebody please have a look at my code and explain why its failing to pass some of thee testcases...
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Substring Comparisons
You are viewing a single comment's thread. Return to all comments →
int l= c.length(); char minchar=Character.MAX_VALUE; int sum1=0; int sum2=0;