MediumPro challengeJavaScriptTypeScript

Selector Memoization

ReactMemoizationSelectors

Implement createSelector(...inputSelectors, computeFn): returns a
memoized selector that re-runs computeFn only when any input selector's
output changes (compared with Object.is).

solve(states) runs a selector that doubles state.count and counts
how many times computeFn was called.

Sample tests

Test #1No states
Input: [[]]
Output: 0
Test #22 unique values → 2 computes
Input: [[{"count":5},{"count":5},{"count":6},{"count":6}]]
Output: 2
Test #3Same count → 1 compute
Input: [[{"count":1},{"count":1},{"count":1}]]
Output: 1
Test #43 different counts
Input: [[{"count":1},{"count":2},{"count":3}]]
Output: 3
Test #5Other prop irrelevant
Input: [[{"count":1,"other":"a"},{"count":1,"other":"b"}]]
Output: 1