Can anyone tell me why "rtaeg" is the scramble string of "great"?


  • 0
    A

    my understanding of word scramble is 'g' and 'r' will stay on same side, either left or right of root node of binary tree. how come the expected result of "great" and "rtaeg" is "true"?


  • 1
    M

    if you consider the following tree

            great
            /      \
           g      reat
                    /   \
                   r  eat
                   /   /  \
                  r   ea t
                       /\
                      e a  
    

    and swap chilren of great and children eat and children of ea

            rtaeg
            /       \
          rtae    g
           /  \
         r    tae           
               / \  
              t   ae
                   /\
                 a  e

Log in to reply
 

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