-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathStringCode.java
More file actions
39 lines (33 loc) · 1.01 KB
/
Copy pathStringCode.java
File metadata and controls
39 lines (33 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.util.HashSet;
import java.util.Set;
// CS108 HW1 -- String static methods
public class StringCode {
/**
* Given a string, returns the length of the largest run.
* A a run is a series of adajcent chars that are the same.
* @param str
* @return max run length
*/
public static int maxRun(String str) {
return 0; // YOUR CODE HERE
}
/**
* Given a string, for each digit in the original string,
* replaces the digit with that many occurrences of the character
* following. So the string "a3tx2z" yields "attttxzzz".
* @param str
* @return blown up string
*/
public static String blowup(String str) {
return null; // YOUR CODE HERE
}
/**
* Given 2 strings, consider all the substrings within them
* of length len. Returns true if there are any such substrings
* which appear in both strings.
* Compute this in linear time using a HashSet. Len will be 1 or more.
*/
public static boolean stringIntersect(String a, String b, int len) {
return false; // YOUR CODE HERE
}
}