bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
MediumMath & GeometryLC 640

Solve the Equation

Solve a given equation and return the value of 'x' in the form of a string "x=#value ". The equation contains only '+', '-' operation, the variable 'x' and its coefficient. You should return "No solution " if there is no solution for the equation, or "Infinite solutions " if there are infinite solutions for the equation. If there is exactly one solution for the equation, we ensure that the value of 'x' is an integer.

Asked at 3 companies
AmazonGoogleUber
Hints
  • 1.Think about which data structure fits best
  • 2.Consider the time complexity of your approach
  • 3.Look for patterns in the constraints
LeetCode