Population Standard Deviation
Updated
Problem statement
Return the population standard deviation of the integers in nums.
For this exercise, let n = nums.length and let mean be the sum divided by n. The answer is the square root of the sum of (nums[i] - mean)^2 divided by n. A one-element or constant array therefore returns zero.
Use floating-point arithmetic and do not round to a fixed number of decimal places. Use the population denominator.
Function
standardDeviation(nums: int[]) → doubleExamples
Example 1
nums = [2,4,4,4,5,5,7,9]return = 2.0The mean is 5. Squared deviations total 32, so population variance is 32/8 = 4 and standard deviation is 2.
Example 2
nums = [1,2,3]return = 0.816496580927726The mean is 2 and squared deviations total 2. Return sqrt(2/3), approximately 0.8164965809.
Constraints
- For this exercise, assume
1 <= nums.length <= 1000. -1000000 <= nums[i] <= 1000000.- Return a finite nonnegative floating-point value. An answer is accepted within absolute or relative error
10^-6.
More JP Morgan Chase Online Assessment questions
- Find Total CostOA · Seen Oct 2026
- Minimum Meeting RoomsOA · Seen Oct 2026
- Count Dropped RequestsOA · Seen Oct 2026
- Maximize Minimum Deployment DifficultyOA · Seen Oct 2026
- Task SchedulingOA · Seen Oct 2026
- Substring RemovalOA · Seen Oct 2026
- Maximum Game Board ScoreOA · Seen Sep 2026
- Minimum Digit Changes Between String HalvesOA · Seen Sep 2026
- Same Substring Within BudgetOA · Seen Sep 2026
- Invert Ad Visibility BitsOA · Seen Aug 2026
Similar questions at other companies
- Count Valid Square PairsAuxoAI · OA
- Picked Player Who LostSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Server InvestmentRippling · OARippling interview questions
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Next Pascal Row CoefficientIntuit · OAIntuit interview questions
- Unique Integers That Sum to ZeroNVIDIA · OANVIDIA interview questions
- Count Multiples of Three with Two SevensHudson River Trading · OAHudson River Trading interview questions
- Diagonal Bounce TraversalAutodesk · OAAutodesk interview questions
- Maximum Student-Teacher DistanceChubb · OAChubb interview questions
- Maximum Three-Server Difficulty ScoreVisa · OAVisa interview questions
Interview reports that mention this question
JP Morgan Chase interview experiences
- JPMorgan Quant Stats Superdays: 3 Experiences (Part 3 of 3)
- JPMorgan Quant Modeling Superdays: 7 Experiences (Part 2 of 3)
- JPMorgan Quant Intern Superday: 19 Experiences (Part 1 of 3)
- JPMorgan Code for Good India 2024: 6 Experiences (Part 5 of 5)
- JPMorgan Code for Good India: 10 Experiences (Part 4 of 5)