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.
- Prepare
- Java
- Strings
- Java Substring Comparisons
- Discussions
Java Substring Comparisons
Java Substring Comparisons
Sort by
recency
|
1762 Discussions
|
Please Login in order to post a comment
public static String getSmallestAndLargest(String s, int k) { String smallest = ""; String largest = "";
}
public static void main(String[] args) { Scanner scan = new Scanner(System.in); String s = scan.next(); int k = scan.nextInt(); scan.close();
}
Used selection sort(kinda) import java.util.Scanner;
public class Solution {
}
Using "Sliding Window Technique"
public static String getSmallestAndLargest(String s, int k) { String smallest = s.substring(0, k); String largest = s.substring(0, k);
solution
import java.util.Scanner;
public class Solution {
}
public static String getSmallestAndLargest(String s, int k) { int length = s.length(); // initialize with the first substring String smallest = s.substring(0, k); String largest = s.substring(0, k);