We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Forgive me if I explain this poorly, but allow me to try. Basically if you are given a function "f(x)" which has a result of "y", then the inverse function "g(y)" would output "x". A function and its inverse are two functions f and g such that calling f(g(x)) will result in x and the same is true for calling g(f(y)) resulting in y. The inverse function will "undo" the operation of the other fuction.
For example, if you take x^2=y (x squared with the result of y) then the inverse function is square root. sqrt(y) = x. So if f(x) is squaring a number and g(x) is taking the square root of a number then calling g(f(x)) is equivalent to squaring a number and then taking the square root of that number ultimately resulting in the number you started with:
sqrt(x^2) = x
...
And for test case 3, well, that is simply broken like the entire question.
I hope this helps.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Security Function Inverses
You are viewing a single comment's thread. Return to all comments →
Forgive me if I explain this poorly, but allow me to try. Basically if you are given a function "f(x)" which has a result of "y", then the inverse function "g(y)" would output "x". A function and its inverse are two functions f and g such that calling f(g(x)) will result in x and the same is true for calling g(f(y)) resulting in y. The inverse function will "undo" the operation of the other fuction. For example, if you take x^2=y (x squared with the result of y) then the inverse function is square root. sqrt(y) = x. So if f(x) is squaring a number and g(x) is taking the square root of a number then calling g(f(x)) is equivalent to squaring a number and then taking the square root of that number ultimately resulting in the number you started with: sqrt(x^2) = x
...
And for test case 3, well, that is simply broken like the entire question.
I hope this helps.