<commit_before><commit_msg>Flatten Binary Tree to Linked List<commit_after>/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */
class Solution {
public:
    void flatten(TreeNode* root) {
        if (!root)
            return;
        TreeNode *dummy = new TreeNode(), *pre;
        pre = dummy;
        std::stack<TreeNode*> s;
        s.emplace(root);
        while (!s.empty()) {
            root = s.top();
            s.pop();
            if (root->right)
                s.emplace(root->right);
            if (root->left)
                s.emplace(root->left);
            root->left = nullptr;
            pre->right = root;
            pre = pre->right;
        }
        root = dummy->right;
    }
};
{'fraction_non_alphanumeric': 0.15483234714003946, 'fraction_numerical': 0.0009861932938856016, 'mean_word_length': 1.835195530726257, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5669871', 'n_tokens_mistral': 314, 'n_tokens_neox': 314, 'n_words': 76}