https://leetcode.com/problems/find-subarrays-with-equal-sum/description/
Find Subarrays With Equal Sum - LeetCode
Can you solve this real interview question? Find Subarrays With Equal Sum - Given a 0-indexed integer array nums, determine whether there exist two subarrays of length 2 with equal sum. Note that the two subarrays must begin at different indices. Return tr
leetcode.com
1
2
3
4
5
6
7
8
9
10
|
class Solution:
def findSubarrays(self, nums: List[int]) -> bool:
sum_nums = []
for i in range(1, len(nums)):
if (nums[i] + nums[i -1]) not in sum_nums:
sum_nums.append((nums[i] + nums[i -1]))
else:
return True
return False
|
cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 2553. Separate the Digits in an Array (0) | 2023.03.14 |
---|---|
leetcode 1122. Relative Sort Array (0) | 2023.03.13 |
백준 27866 문자와 문자열 (0) | 2023.03.13 |
leetcode 2451. Odd String Difference (0) | 2023.03.08 |
leetcode 2264. Largest 3-Same-Digit Number in String (0) | 2023.03.07 |
댓글