[Python Two Pointers] The most standard template for Two Pointers
I would say: although those 1-liner solutions are fancy, but as a SWE, \nthe step by step thinking with strict logic is essentially the most significant treasur
I would say: although those 1-liner solutions are fancy, but as a SWE, \n**the step by step thinking with strict logic is essentially the most significant treasure and is precious.**\n```\nclass Solution:\n    def flipAndInvertImage(self, image: List[List[int]]) -> List[List[int]]:\n        \n        def reverse(listt, left, right):\n            \n            while left < right:                \n                listt[left], listt[right] = listt[right], listt[left]\n                \n                left += 1\n                right -= 1\n        \n        \n        # 1. reverse every list in image\n        for listt in image:\n            reverse(listt, 0, len(listt) - 1)\n        \n        # 2. invert every elements in the matrix\n        for i in range(len(image)):\n            for j in range(len(image[0])):\n                \n                if image[i][j] == 0:\n                    image[i][j] = 1\n                    \n                elif image[i][j] == 1:\n                    image[i][j] = 0\n        \n        return image\n```
['Two Pointers', 'Python']