22 Sep Java Substring Comparisons – Hacker Rank Solution
HomeHackerRank JavaJava Substring Comparisons – Hacker Rank Solution Afzal Imam September 06, 2021 Hello Friends, How are you? Today I am going to solve the HackerRank Java Substring Comparisons Problem with a very easy explanation. This is the 16th problem of Java on HackerRank. In this article, you will get more than one approach to solve this problem. So let’s start- We define the following terms: A < B < …. < Y < Z < a < b < ….. < y < z For example, ball < cat, dog < dorm, Happy < happy, Zoo < ball. A substring of a string is a contiguous block of characters in the string. For example, the substrings of abc are a, b, c, ab, bc, and abc. Given a string, s, and an integer, k, complete the function so that it finds the lexicographically smallest and largest substrings of length k. Complete the getSmallestAndLargest function in the editor below. getSmallestAndLargest has the following parameters:
- string s: a string
- int k: the length of the substrings to find
- string: the string ‘ + “\n” + ‘ where and are the two substrings
The first line contains a string denoting s. The second line contains an integer denoting k.
- 1
Sorry, the comment form is closed at this time.