I am trying to solve two sum problem on leetcode but want to come up with an algorithm that is less than O(n2) time complexity?
Here is my code so far
new_list = [(i , j) for i in range(len(nums_2)) for j in range(i + 1, len(nums_2)) if nums_2[i] + nums_2[j] == target_1] print(list(new_list))
How can I remove the parenthesis or brackets around my output.
Output: [(1, 2)]
if i replace the parenthesis around (i , j)
it becomes [[1 , 2]]
submitted by /u/TheEyebal
[link] [comments]
r/learnpython I am trying to solve two sum problem on leetcode but want to come up with an algorithm that is less than O(n2) time complexity? Here is my code so far new_list = [(i , j) for i in range(len(nums_2)) for j in range(i + 1, len(nums_2)) if nums_2[i] + nums_2[j] == target_1] print(list(new_list)) How can I remove the parenthesis or brackets around my output. Output: [(1, 2)] if i replace the parenthesis around (i , j)it becomes [[1 , 2]] submitted by /u/TheEyebal [link] [comments]
I am trying to solve two sum problem on leetcode but want to come up with an algorithm that is less than O(n2) time complexity?
Here is my code so far
new_list = [(i , j) for i in range(len(nums_2)) for j in range(i + 1, len(nums_2)) if nums_2[i] + nums_2[j] == target_1] print(list(new_list))
How can I remove the parenthesis or brackets around my output.
Output: [(1, 2)]
if i replace the parenthesis around (i , j)
it becomes [[1 , 2]]
submitted by /u/TheEyebal
[link] [comments]