Given an equation of the form:
a + b = c
Out of which any one of the terms , or is missing. The task is to find the missing term.
Input: 2 + 6 = ? Output: 8 Input: ? + 3 =6 Output: 3
Approach: Missing number can be found simply using the equation . First, we will find two known numbers from the given equation(read as a string in the program) and convert them into integers and put into the equation. In this way, we can find the third missing number. We can implement it by storing the equation into the string.
Below is the step by step algorithm:
- Split the string into smaller strings from the position of spaces and store in an array. So that the array will contain:
arr = "a" arr = "+" arr = "b" arr = "=" arr = "c"
- The missing character can occur at the position 0 or 2 or 4 in the vector. Find the position of missing character.
- Convert known characters to integer.
- Find missing character using the equation.
Below is the implementation of the above approach:
- Find four factors of N with maximum product and sum equal to N | Set 3
- Check if the given 2-D points form T-shape or not
- Minimum changes required to make two arrays identical
- Maximize the product of four factors of a Number
- Find Nth term (A matrix exponentiation example)
- How can competitive programming help you get a job?
- Burst Balloon to maximize coins
- Minimum number of elements to be removed to make XOR maximum
- What coding habits improve timing in coding contest?
- Maximum Possible Product in Array after performing given Operations
- Sum of decimal equivalent of all possible pairs of Binary representation of a Number
- Count strings with consonants and vowels at alternate position
- How to get rid of Java TLE problem
- Triplet with no element divisible by 3 and sum N
- Count number of primes in an array
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.