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.
Fibonacci Modified
Fibonacci Modified
Sort by
recency
|
711 Discussions
|
Please Login in order to post a comment
My solution Js, using memoization and closures.
this problem can't be solved in c# unless you modify the return type, int can't handle the upper bound, so changed to string, used BigInteger internally and then it worked, this should be fixed in order to actually solve the problem, as it state "The function is expected to return an INTEGER." that is not valid
/ /\ /\ /\
public static BigInteger fibonacciModified(int t1, int t2, int n) { // Write your code here List results = new ArrayList<>(); results.add(BigInteger.valueOf(t1)); results.add(BigInteger.valueOf(t2)); BigInteger result = BigInteger.valueOf(0); for( int i =2;i
Kotlin O(n) time O(1) memory solution