Isn't this insane how a small change (pass by reference) allows TLE to become AC
Isn\'t this insane how this small change allows the same solution to pass? Shouldn\'t leetcode be able to discern this is not some major change and allow both?\
Isn\'t this insane how this small change allows the same solution to pass? Shouldn\'t leetcode be able to discern this is not some major change and allow both?\n\nAccepted\n```\nclass Solution {\npublic:\n    int res, n;\n    string str;\n    bool isPalin(string s, int n) {\n        for (int i=0; i<n/2; i++) {\n            if (s[i] != s[n-1-i]) return false;\n        }\n        return true;\n    }\n    int max(int a, int b) {\n        if (a >= b) {\n            return a;\n        }\n        return b;\n    }\n    int max(int a, int b, int c) {\n        int m = max(a,b);\n        return max(m,c);\n    }\n    int go(int idx, string &s1, string &s2) {\n        if (idx == n) {\n            int l1 = s1.size();\n            int l2 = s2.size();\n            if (isPalin(s1, l1) && isPalin(s2, l2)) {\n                res = max(res, l1*l2);\n            }\n            return res;\n        }\n        string s3 = s1 + str[idx];\n        string s4 = s2 + str[idx];\n        return max(go(idx+1, s1, s2), go(idx+1, s3, s2), go(idx+1, s1, s4));\n    }\n    int maxProduct(string s) {\n        n = s.size();\n        res = 0;\n        str = s;\n        string s1 = "";\n        string s2 = "";\n        return max(go(0,s1,s2), res);\n    }\n};\n```\n\nTLE:\n```\nclass Solution {\npublic:\n    int res, n;\n    string str;\n    bool isPalin(string s, int n) {\n        for (int i=0; i<n/2; i++) {\n            if (s[i] != s[n-1-i]) return false;\n        }\n        return true;\n    }\n    int max(int a, int b) {\n        if (a >= b) {\n            return a;\n        }\n        return b;\n    }\n    int max(int a, int b, int c) {\n        int m = max(a,b);\n        return max(m,c);\n    }\n    int go(int idx, string s1, string s2) {\n        if (idx == n) {\n            int l1 = s1.size();\n            int l2 = s2.size();\n            if (isPalin(s1, l1) && isPalin(s2, l2)) {\n                res = max(res, l1*l2);\n            }\n            return res;\n        }\n        return max(go(idx+1, s1, s2), go(idx+1, s1 + str[idx], s2), go(idx+1, s1, s2 + str[idx]));\n    }\n    int maxProduct(string s) {\n        n = s.size();\n        res = 0;\n        str = s;\n        return max(go(0,"",""), res);\n    }\n};\n```
[]