87.Scramble-String

87. Scramble String

้ข˜็›ฎๅœฐๅ€

https://www.lintcode.com/problem/scramble-string/descriptionarrow-up-right

https://leetcode.com/problems/scramble-string/arrow-up-right

้ข˜็›ฎๆ่ฟฐ

Given a string s1, we may represent it as binary tree by partitioning it to two non-empty substrings recursively.

Below is one possible representation of s1 = "great":
        great
       /     \
    gr        eat
  /    \      / \
g       r    e   at
                 / \
                a   t

Approach #1

exponential complexity O(2^n)

Last updated