This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class LetterCombinations { | |
private static final Map<Character, String> mapping = new HashMap<>(); | |
static { | |
mapping.put('2', "abc"); mapping.put('3', "def"); mapping.put('4', "ghi"); | |
mapping.put('5', "jkl"); mapping.put('6', "mno"); mapping.put('7', "pqrs"); | |
mapping.put('8', "tuv"); mapping.put('9', "wxyz"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mce_BK(R, P, X, g, cliques): | |
if not P and not X: | |
cliques.append(R) | |
for v in degeneracy_ordering(P, g): | |
mce_BK(R | set([v]), P & g.neighbors(v), X & g.neighbors(v), | |
g, cliques) | |
P.remove(v) | |
X.add(v) | |
def degeneracy_ordering(P, g): |