Skip to content

Commit

Permalink
Create November-07.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Hunterdii authored Nov 6, 2024
1 parent cfb29c9 commit 159f552
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions November 2024 GFG SOLUTION/November-07.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#User function Template for python3
class Solution:
def findSplit(self, arr):
n = len(arr)
totalSum = sum(arr)

if totalSum % 3 != 0:
return [-1, -1]

target = totalSum // 3
currentSum = 0
countFirst = 0

for i in range(n):
currentSum += arr[i]

if currentSum == 2 * target and countFirst > 0:
return [countFirst - 1, i]

if currentSum == target:
countFirst += 1

return [-1, -1]

#{
# Driver Code Starts
# Initial Template for Python 3

# Main
if __name__ == '__main__':
t = int(input())
while t:
t -= 1
arr = [int(x) for x in input().strip().split()]

ob = Solution()
result = ob.findSplit(arr)

if result == [-1, -1]:
print("false")
else:
print("true")
print("~")

# } Driver Code Ends

0 comments on commit 159f552

Please sign in to comment.