Recover swapped BST

Write codeMedium30 minMeta style

Your task

A binary search tree had exactly two of its node values swapped by mistake. Given the (possibly corrupted) tree as a level-order array (None marks a missing child), recover it by swapping those two values back, then return the corrected inorder traversal (which must be strictly increasing). Find the two offending nodes during a single inorder walk: the inorder sequence of a BST is sorted, so the swapped pair shows up as one or two descents. Return the corrected inorder list.

Examples

recover_bst_inorder(level: list) -> list[int]
Example 1
Inputrecover_bst_inorder([1, 3, None, None, 2])
Output[1, 2, 3]