-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuddy2.java
More file actions
27 lines (20 loc) · 824 Bytes
/
buddy2.java
File metadata and controls
27 lines (20 loc) · 824 Bytes
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
import java.util.*;
public class buddy2 {
public static boolean buddyStrings(String s, String goal) {
// if they are not the same length, return false
// if they are the same strings, if there are repeated chars; yes-true
// same len, diff strings; if there are 2 unique chars,
}
public static void main(String[] args) {
String s = "aaaaaaabc";
String goal = "aaaaaaacb";
System.out.println("Output: " + buddyStrings(s, goal));
}
}
// 1. test they are the same length
// 2. if A==B, if there are repeated chars, return true
// 3. else count number of differences; if there are only 2
// AND the strings are equal after swap, return tru
// 1.
// 2.
// 3.