'Time complexity of pushing elements using Object.values(test[i])
What would be the time complexity of doing something like:
// assume all values are primitives
const result = [];
for(const test of tests){
result.push(Object.values(test));
}
I know that Object.keys is O(n) and thus assume the same for Object.values, which makes me believe this is O(n²), but I'm looking for a concrete answer.
Solution 1:[1]
since: enter link description here
Object.values Method: Happens in O(N)
and you have a nested "for", your believes are right and your algorithm have a O(n²) time complexity resolution
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | devperate |
