C++ || C# || Python || shortest || clean solution
We only need to count the L and R, then we use the total length subtract the number of L and R pair that cancels each other out.\nWe can express the L and R pai
We only need to count the L and R, then we use the total length subtract the number of L and R pair that cancels each other out.\nWe can express the L and R pair using the  min(L_count, R_count) * 2\n\nC++\n\n\tclass Solution {\n\tpublic:\n\t\tint furthestDistanceFromOrigin(string moves) {\n\t\t\tint rc = 0, lc = 0;\n\t\t\tfor (auto &move: moves) {\n\t\t\t\tif (move == \'R\') rc++;\n\t\t\t\tif (move == \'L\') lc++;\n\t\t\t}\n\t\t\treturn moves.size() - min(lc, rc) * 2;\n\t\t}\n\t};\n\t\nC#\n\n\tpublic class Solution {\n\t\tpublic int FurthestDistanceFromOrigin(string moves) {\n\t\t\tint rc = 0, lc = 0;\n\t\t\tforeach (var move in moves) {\n\t\t\t\tif (move == \'R\') rc++;\n\t\t\t\tif (move == \'L\') lc++;\n\t\t\t}\n\t\t\treturn moves.Length - Math.Min(lc, rc) * 2;    \n\t\t}\n\t}\n\nPython\n\n\tclass Solution:\n\t\tdef furthestDistanceFromOrigin(self, moves: str) -> int:\n\t\t\treturn len(moves) - min(moves.count(\'R\'), moves.count(\'L\')) * 2\n
['C', 'Python']