https://github.com/climax-solution/energyweb
https://github.com/climax-solution/energyweb
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/climax-solution/energyweb
- Owner: climax-solution
- Created: 2023-04-26T15:27:17.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-26T15:31:21.000Z (about 3 years ago)
- Last Synced: 2025-01-22T12:45:28.538Z (over 1 year ago)
- Language: TypeScript
- Size: 95.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Energy Web - JavaScript/TypeScript Developer recruitment task
In this version, I filtered the movies based on the number of matching genres and then sort them by the number of genres and id. The complexity of this function is as follows:
1. The filter function iterating over the movies has a time complexity of O(m), where m is the number of movies.
2. The sort function at the end has a time complexity of O(m * log(m)) in the average and worst case, as it uses the built-in sorting algorithm of JavaScript.
Combining these complexities, I get a total time complexity of O(m) + O(m * log(m)). In this case, the dominant term is O(m * log(m)) as the complexity of sorting dominates the linear complexity of filtering.
So, the time complexity of this getFilteredMovies function is O(m * log(m)).