Timeline for Better way for accumulating a value than using inject/reduce with conditional operator?
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 18, 2014 at 21:49 | comment | added | tokland |
array.include?(item) is O(n) on arrays but O(1) on set. set = array.to_set and then use it for inclussion tests.
|
|
May 18, 2014 at 21:35 | comment | added | user2609980 |
triangles is an array of integers, yes. @tokland what do you mean with a O(1) inclusion predicate/set and how would I implement this?
|
|
May 17, 2014 at 18:11 | comment | added | tokland |
triangles is an array? better a structure with O(1) inclusion predicates (i.e. a set).
|
|
May 17, 2014 at 15:47 | vote | accept | user2609980 | ||
May 17, 2014 at 15:07 | answer | added | Anonymous | timeline score: 3 | |
May 17, 2014 at 14:20 | history | asked | user2609980 | CC BY-SA 3.0 |