[C++/Java] Explained - easy iterative solution O(n) || with single pointer
Approach\n- iterate over the start and target simultaneously\n- Take two counters lcount and rcount.\n- When we see L or R in start we increement and if we see 
# Approach\n- iterate over the start and target simultaneously\n- Take two counters lcount and rcount.\n- When we see L or R in start we increement and if we see the same in target we decrement both l and r counter\n- Now there are 5 cases where we need to return false :\n 1. When lcount is greater than zero that means we have seen one L in start but not its equivalent in target till i which means we can not compensate it anymore so return false.\n 2. opposite of above case when we see extra R in the target i.e when the rcount is less than 0 then return false;\n 3. When we see L in start but the rcount is not zero return false;\n 4. When we see R in target but the lcount is not zero return false;\n 5. At the end of iterations if still any of rcount or lcount is not zero then return zero.\n\n- If non of the above cases found then return true;\n\n# Complexitey:\n- Time complexity : O(N)\n- Space complexity : O(1)\n\n# C++ code\n\n```\nbool canChange(string start, string target) {\n    int lcount = 0, rcount = 0;\n    for(int i  = 0; i < start.size(); ++i){\n        if(start[i] == \'L\') { lcount++; if(rcount != 0) return false; }\n        if(target[i] == \'L\'){ lcount--; }\n        if(start[i] == \'R\') { rcount++; }\n        if(target[i] == \'R\'){ rcount--; if(lcount != 0) return false; }\n        if(lcount > 0 || rcount < 0) return false;\n    }\n    return !(lcount != 0 || rcount != 0);\n}\n```\n\n# Java code\n\n```\npublic boolean canChange(String start, String target) {\n    int lcount = 0, rcount = 0;\n    for(int i  = 0; i < start.length(); ++i){\n        if(start.charAt(i) == \'L\') { lcount++; if(rcount != 0) return false; }\n        if(target.charAt(i) == \'L\'){ lcount--; }\n        if(start.charAt(i) == \'R\') { rcount++; }\n        if(target.charAt(i) == \'R\'){ rcount--; if(lcount != 0) return false; }\n        if(lcount > 0 || rcount < 0) return false;\n    }\n    return !(lcount != 0 || rcount != 0);\n}\n\n```\n\n\n\n---\n\n\n<b>Here is an article of my interview experience - A Journey to FAANG Company, I recomand you to go through this to know which all resources I have used & how I cracked interview at Amazon:\nhttps://leetcode.com/discuss/interview-experience/3171859/Journey-to-a-FAANG-Company-Amazon-or-SDE2-(L5)-or-Bangalore-or-Oct-2022-Accepted\n\n\n---\n
['String', 'C']