String pyramid transition matrix


  • 0
    P

    I was asked the below question in my Google phone interview.
    Problem: given a list of leaf nodes in a pyramid ,and a map which indicates what's the possible parent node given a left and right node. Return true if the one of leaf node could turn into the root node, Otherwise, return false.
    '''
    Example:

     root
     / \
    X   X
    

    /\ /
    X X X
    / / /
    A B C D
    Map:

       left:  A     |  B       |      C | D
    

    right ---------------------------------
    A B | A or C | D | A
    B D |B or C | A |
    C B
    D
    '''
    Note:1. If left child is B, right child is A, the parent node could be B or C

    Refer: https://stackoverflow.com/questions/43432699/string-pyramid-transition-matrix


  • 0
    P

    Can someone help with pseudo code or algorithm? Thanks.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.