5 ms·
Just wanted to add a more functional solution: def miss_pos(a): b = range(1, len(a)+2) return min(set(b).difference(a)) It's probably not
by falcor84 12y ago
Just wanted to add a more functional solution:
def miss_pos(a):
b = range(1, len(a)+2)
return min(set(b).difference(a))
It's probably not as efficient, but remember the first rule of optimization: http://c2.com/cgi/wiki?FirstRuleOfOptimization http://c2.com/cgi/wiki?FirstRuleOfOptimization
- innguest 12y agoI wonder why so much discussion about arbitrary rules of assignment when the solution to the problem can be written (and is more readable) without ever mentioning this complicated "assignment" feature.