Skip to content

Commit 737bb4a

Browse files
Update and rename Interview10 to Interview10.java
1 parent 88d848e commit 737bb4a

1 file changed

Lines changed: 1 addition & 17 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
11
class Pramp {
2-
public static void main(String[] args) {
3-
String pramp = "Practice Makes Perfect";
4-
System.out.println(pramp);
5-
}
6-
2+
73
public static String get(String s, char[] a) {
84
if (a == null || a.length == 0 || s == null || s.length() == 0 || a.length > s.legnth())
95
return null;
106
String r = null;
117
int[] c = new int[256];
128
for (int i=0; i< a.length; i++)
139
c[s.charAt(i)]++;
14-
if (allPresent(a, c)) // S= xyyzzyx -> zyx, zyx
15-
return s.substring(0, a.length);
16-
1710
int i = 0, j = a.length - 1;
18-
19-
// S= xyyzzyx | a = zyx
20-
// xyyz zyx
21-
// s = 0 e 3 | s = 5 e= s.length;
22-
// s.length = 8, a.length = 3 ... 8 - 3 = i = 5, j == 8
2311
while (i <= s.length() - a.length && j <= s.length()) {
2412
if (allPresent(a, c)) {
2513
r = (r == null || r.length() > j - i) ? s.substring(i, j) : r; // 5, 8
@@ -32,7 +20,6 @@ public static String get(String s, char[] a) {
3220
c[s.charAt(j)]++;
3321
}
3422
}
35-
3623
return r;
3724
}
3825

@@ -44,7 +31,4 @@ public static boolean allPresent(char[] a, int[] c) {
4431
}
4532
return true;
4633
}
47-
48-
49-
5034
}

0 commit comments

Comments
 (0)