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

  • 0

    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

    if you consider the following tree

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

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

            /       \
          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.