C++| O(N) |🗓️ Daily LeetCoding Challenge May, Day 1
Iterate from reverse.\n If \'#\' found, count occurences. \n If normal charachter found skip it if counter for "#" is not 0.\n Otherwise compare character betwe
* Iterate from reverse.\n* If \'#\' found, count occurences. \n* If normal charachter found skip it if counter for "#" is not 0.\n* Otherwise compare character between the two strings. \n* TC : O(N + M)\n```\nclass Solution {\npublic:\n    bool backspaceCompare(string s, string t) {\n        \n        int n = s.length(), m = t.length();\n        bool ans = true;\n        \n        int ptr1 = n-1, ptr2 = m-1, s_bck = 0, t_bck = 0;\n        \n        while(ptr1>=0 and ptr2>=0){\n           \n            if(s[ptr1] == \'#\'){\n                s_bck++;\n                ptr1--;\n                continue;\n            }\n            \n            if(t[ptr2] == \'#\'){\n                t_bck++;\n                ptr2--;\n                continue;\n            }\n            \n            if(s_bck>0){\n                ptr1--;\n                s_bck--;\n                continue;\n            }\n            \n            if(t_bck>0){\n                ptr2--;\n                t_bck--;\n                continue;\n            }\n            \n            if(s[ptr1] != t[ptr2]){\n                ans = false;\n                break;\n            }\n            \n            ptr1--;\n            ptr2--;\n            \n           \n        }\n        \n        while(ptr1>=0){\n            if(s[ptr1] == \'#\'){\n                s_bck++;\n                ptr1--;\n                continue;\n            }\n            \n            if(s_bck>0){\n                s_bck--;\n                ptr1--;\n                continue;\n            }\n            \n            break;\n        }\n        \n        while(ptr2>=0){\n            if(t[ptr2] == \'#\'){\n                t_bck++;\n                ptr2--;\n                continue;\n            }\n            \n            if(t_bck>0){\n                t_bck--;\n                ptr2--;\n                continue;\n            }\n            \n            break;\n        }\n        \n        if(ptr1>=0 || ptr2>=0){\n            ans = false;\n        }\n        \n        return ans;\n        \n    }\n};\n```
['Two Pointers', 'C']