1def solveEquation(self, equation: str) -> str:2""" O(N)TS """3x, y, p = 0, 0, 14for i in re.finditer(r"=|[+-]?\d*x|[+-]?\d+", equation):5g = i.group()6if g == '=':7p = -18elif g[-1] == 'x':9x += p * int(g.replace('x', '1' if len(g) == 1 or not g[-2].isdigit() else ''))10else:11y += -p * int(g)1213if x == 0 == y:14return 'Infinite solutions'15elif x == 0:16return "No solution"17return f'x={y // x}'