xxx

xxx
mail@pastecode.io avatar
unknown
java
a year ago
861 B
1
Indexable
Never
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class GenerateKey {

    public static String generateKey(List<Integer> duplicates, List<Integer> missing) {
        StringBuilder stringBuilder = new StringBuilder();
        duplicates.forEach(v -> stringBuilder.append(v).append(","));
        stringBuilder.append("#");
        missing.forEach(v -> stringBuilder.append(v).append(","));
        return stringBuilder.toString();
    }

    public static void main(String[] args) {
        int[] duplicates = {1, 1, 2};
        int[] missing = {2, 3, 4};
        System.out.println(
                generateKey(
                        Arrays.stream(duplicates).boxed().collect(Collectors.toList()),
                        Arrays.stream(missing).boxed().collect(Collectors.toList())));
    }

}