Skip to content

Feat: Add solution for the externship task#177

Open
aguyran wants to merge 1 commit intosymblai:mainfrom
aguyran:main
Open

Feat: Add solution for the externship task#177
aguyran wants to merge 1 commit intosymblai:mainfrom
aguyran:main

Conversation

@aguyran
Copy link
Copy Markdown

@aguyran aguyran commented Dec 19, 2021

  • Externship Task Completed
  • All Tasks Passed

Approach

  • Iterated over the equation and maintained character into a temporary variable token to keep track of current digits or symbols and pushed it to an array called split whenever empty space encountered(" ").
  • whenever question mark encountered it can be said it is at the number at split array length as indexing is from 0 but length is total no. of elements so store it in positionOfQues
  • Now we have 4 equations, ex if question mark is there in first number (D-C/B)=?
  • Use the correct equation according to the positionOfQues, and use eval to solve it
  • if there would be a 0 at left it would be automatically removed because its a number so we just check the length of answer with original, if they don't match 0 was on the left side or answer was not possible.
  • Now if lengths match we check all the digits of the question with Answer minus the digit at ? if it matches we return position of question mark in answer otherwise -1
  • Map to check test cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant