Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class MyTest{
- static List<String> GetCombination(String[][] input){
- List<String> temp = new ArrayList<String>();
- List<String> result = new ArrayList<String>();
- result.add("");
- for (String[] a : input){
- for (String s : a){
- for (String r : result){
- temp.add(s+r);
- }
- }
- result = new ArrayList<String>(temp);
- temp.clear();
- }
- return result;
- }
- public static void main(String[] args) {
- String[][] input = {
- { "a", "b", "c", "d", "e" },
- { "+", "-", "*", "/" },
- { "1", "2" },
- };
- List<String> result = GetCombination(input);
- System.out.println(result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement