-
-
Notifications
You must be signed in to change notification settings - Fork 153
Glasgow | May 2025 | Salah Ahmed | Data Groups | Sprint 1 #569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ove median calculation logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good solutions here, I have left one questions for you to answer
//Notes / Limitations: | ||
//Time complexity is O(n²): Inefficient for large arrays. | ||
//Mutates the input array: If you need to preserve the original, you'll need to copy it first. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good analysis of this solution's complexity. Lots of nested loops within loops should be avoided where possible. Your other solution is clever, making use of existing javascript functionality.
const numericElements = elements.filter(element => typeof element === 'number'); | ||
|
||
// Return the sum of numeric elements | ||
return numericElements.reduce((acc, curr) => acc + curr, 0); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good use of the reduce function here
…for improved performance
Self checklist
Changelist
I have solved all issues relaed to sprint 1 in Data Group