class Solution(object): def arrayPairSum(self, nums): """ :type nums: List[int] :rtype: int """ return sum(sorted(nums)[::2])
@ecdubs Just put in exactly the same code independently. First time I've ever submitted something that beat 100% of other submissions... I know it's a new problem, but I'll take it.
@benlindsay Lol I mean this is avg O(nlogn) and editorial says it wants O(n) he/she needs to fix it.
@ecdubs You use the function of slices,that's great! as i use the while loop.
@ecdubs is there any O(n) solution? btw, what's the space complexity of sorted in python ,is it O(n) ? I mean sorted will create a new list , is it right ? I am new here :-)
here is the analysis:
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.