void mymethod(int arr[], int k) {
int n = arr.length;
int count = 0;
HashMap<Integer,StringBuilder> map = new HashMap<>();
StringBuilder s = new StringBuilder(),s1 = new StringBuilder();
int c = 1, large = Integer.MAX_VALUE;double lent=1;
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
{
for (int k1 = i; k1 <= j; k1++)
s.append(arr[k1]);
try {
int x = Integer.parseInt(String.valueOf(s.charAt(s.length() - 1)));
int x1 = Integer.parseInt(String.valueOf(s.charAt(0)));
lent = (double) k / (x - x1 + 1);
} catch (Exception ex) {
System.out.println("BOO");
}
s1.append(s);
try {
for (int r = 0; r < lent - 1; r++)
s.append(s1);
s1.setLength(0);
s1.append(sortString(s.toString()));
map.put(c++, new StringBuilder(s1.toString()));
if (s1.length() >= k) {
int temp = Integer.parseInt(String.valueOf(s1.charAt(k - 1)));
if (large >= temp) {
large = temp;
}
}
s.setLength(0);
s1.setLength(0);
}
catch (Exception ex)
{
System.out.println("BOO");
}
}
}
}
for (int i = 1; i <= map.size(); i++) {
String temp = map.get(i).toString();
if (temp.contains(String.valueOf(large)))
count++;
}
//System.out.println(map+" "+large);
//s.setLength(0);
System.out.println(count);
s.setLength(0);
s1.setLength(0);
map.clear();
}