mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 08:16:50 +08:00
merge: Optimize the space complexity of the fibonacci algo (#899)
* docs: update js doc * feat: add number type validation condition * pref: Optimize space complexity remove the Array from the algo and used two flag varible to calculate last two numbers & optimize the sapce complexity O(n) to O(1) * test: add test case for invalid types
This commit is contained in:
@ -1,6 +1,12 @@
|
||||
import { fibonacci } from '../FibonacciNumber'
|
||||
|
||||
describe('FibonacciNumber', () => {
|
||||
describe('Testing FibonacciNumber', () => {
|
||||
it('Testing for invalid type', () => {
|
||||
expect(() => fibonacci('0')).toThrowError()
|
||||
expect(() => fibonacci('12')).toThrowError()
|
||||
expect(() => fibonacci(true)).toThrowError()
|
||||
})
|
||||
|
||||
it('fibonacci of 0', () => {
|
||||
expect(fibonacci(0)).toBe(0)
|
||||
})
|
||||
|
Reference in New Issue
Block a user