Given a list/array of strings, find and group together all strings that are "buddies" with one another. You may use any data structure of your choosing to return the grouping of buddies.
Two strings are "buddies" if they are the same length, and the characters are equal distance from each other.
For example, "aaa" and "zzz" are buddies, but "aaa" would not be buddies with "abc".
Given a formula of letters with parentheses, return a simplified equivalent version of the equation without parentheses.
Examples:
a-(b+c) -> a-b-c
a-(a-b) -> b
This question combines two classic interview tasks: grouping strings by a custom buddy relation, and simplifying a parenthesized letter expression into an equivalent form without parentheses. For the string part, the key is to define the buddy rule precisely and use an efficient grouping structure such as hashing or union-find. For the expression part, the main challenge is tracking sign propagation through parentheses so the final output preserves equivalence. The examples highlight how to expand expressions like a-(b+c) into a-b-c.