Tasks Details
The submission is being evaluated.
The submission is being evaluated.
The submission is being evaluated.
The submission is being evaluated.
The submission is being evaluated.
The submission is being evaluated.
The submission is being evaluated.
The submission is being evaluated.
The submission is being evaluated.
The submission is being evaluated.
The submission is being evaluated.
The submission is being evaluated.
The submission is being evaluated.
The submission is being evaluated.
The submission is being evaluated.
The submission is being evaluated.
The submission is being evaluated.
easy
1.
EquiLeader
Find the index S such that the leaders of the sequences A[0], A[1], ..., A[S] and A[S + 1], A[S + 2], ..., A[N - 1] are the same.
Task Score
100%
Correctness
100%
Performance
100%
A non-empty array A consisting of N integers is given.
The leader of this array is the value that occurs in more than half of the elements of A.
An equi leader is an index S such that 0 ≤ S < N − 1 and two sequences A[0], A[1], ..., A[S] and A[S + 1], A[S + 2], ..., A[N − 1] have leaders of the same value.
For example, given array A such that:
A[0] = 4 A[1] = 3 A[2] = 4 A[3] = 4 A[4] = 4 A[5] = 2we can find two equi leaders:
- 0, because sequences: (4) and (3, 4, 4, 4, 2) have the same leader, whose value is 4.
- 2, because sequences: (4, 3, 4) and (4, 4, 2) have the same leader, whose value is 4.
The goal is to count the number of equi leaders.
Write a function:
def solution(A)
that, given a non-empty array A consisting of N integers, returns the number of equi leaders.
For example, given:
A[0] = 4 A[1] = 3 A[2] = 4 A[3] = 4 A[4] = 4 A[5] = 2the function should return 2, as explained above.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [1..100,000];
- each element of array A is an integer within the range [−1,000,000,000..1,000,000,000].
Copyright 2009–2025 by Codility Limited. All Rights Reserved. Unauthorized copying, publication or disclosure prohibited.
Solution
Programming language used Python
Time spent on task 51 minutes
Notes
not defined yet
Code: 16:50:11 UTC,
java,
autosave
Code: 16:52:55 UTC,
py,
autosave
Code: 16:53:12 UTC,
py,
autosave
Code: 16:53:41 UTC,
py,
autosave
Code: 16:54:10 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if stack[size-1] == A[i]
size -=1
elif
if size == 0:
stack[size] = A[i]
size += 1
else:
elif
Code: 16:54:25 UTC,
py,
autosave
Code: 16:54:42 UTC,
py,
autosave
Code: 16:54:59 UTC,
py,
autosave
Code: 16:55:10 UTC,
py,
autosave
Code: 16:55:20 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
Code: 16:56:07 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
Code: 16:56:35 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
for i in range(len(A)):
if A[i]
Code: 16:56:51 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]
Code: 16:58:46 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]
Code: 16:59:11 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
if count > len(A)/2:
Code: 16:59:33 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
Code: 17:00:15 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
#
Code: 17:00:45 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
Code: 17:00:56 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
Code: 17:08:20 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
ã„‘
Code: 17:08:51 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
for i in range(len(A)):
Code: 17:09:00 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
for i in range(len(A)):
if
Code: 17:09:14 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
curSum = 0
for i in range(len(A)):
if
Code: 17:09:25 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
curSum = 0
for i in range(len(A)):
if A[i] ==
Code: 17:09:55 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
curSum = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
Code: 17:17:09 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
curSum = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
Code: 17:17:22 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
curSum = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find
Code: 17:17:50 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
curSum = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equi
Code: 17:18:04 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
curSum = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
Code: 17:18:47 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
curSum = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
f
Code: 17:18:58 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
curSum = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
for i in range(len(A))
Code: 17:19:09 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
curSum = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
for i in range(len(A)):
if
Code: 17:19:20 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
curSum = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
for i in range(len(A)):
if prefixSum[i]
Code: 17:19:44 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
curSum = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
for i in range(len(A)):
if prefixSum[i] > (i+1)/2 and
Code: 17:19:55 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
curSum = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
for i in range(len(A)):
if prefixSum[i] > (i+1)/2 and prefixSum[]
Code: 17:20:11 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
curSum = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
for i in range(len(A)):
if prefixSum[i] > (i+1)/2 and prefixSum[len(A)-1]-prefixSum[]
Code: 17:20:25 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
curSum = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
for i in range(len(A)):
if prefixSum[i] > (i+1)/2 and prefixSum[len(A)-1]-prefixSum[i] >
Code: 17:20:36 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
curSum = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
for i in range(len(A)):
if prefixSum[i] > (i+1)/2 and prefixSum[len(A)-1]-prefixSum[i] > (len(A)-i)/2:
Code: 17:20:50 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
curSum = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(len(A)):
if prefixSum[i] > (i+1)/2 and prefixSum[len(A)-1]-prefixSum[i] > (len(A)-i)/2:
ans += 1
Code: 17:21:03 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
else
return 0
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
curSum = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(len(A)):
if prefixSum[i] > (i+1)/2 and prefixSum[len(A)-1]-prefixSum[i] > (len(A)-i)/2:
ans += 1
Code: 17:21:27 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*lem(A)
size = 0
for i in range(len(A)):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > len(A)/2:
hasDominator = 1
else
return 0
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
curSum = 0
for i in range(len(A)):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(len(A)):
if prefixSum[i] > (i+1)/2 and prefixSum[len(A)-1]-prefixSum[i] > (len(A)-i)/2:
ans += 1
return ans
Code: 17:21:53 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else
return 0
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*lem(A)
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(len(A)):
if prefixSum[i] > (i+1)/2 and prefixSum[len(A)-1]-prefixSum[i] > (len(A)-i)/2:
ans += 1
return ans
Code: 17:22:04 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else
return 0
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(len(A)):
if prefixSum[i] > (i+1)/2 and prefixSum[len(A)-1]-prefixSum[i] > (len(A)-i)/2:
ans += 1
return ans
Code: 17:22:16 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else
return 0
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
Code: 17:25:26 UTC,
py,
verify,
result: Failed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else
return 0
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
The submission is being evaluated.
Code: 17:25:36 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
Code: 17:25:40 UTC,
py,
verify,
result: Failed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
The submission is being evaluated.
Code: 17:26:02 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
Code: 17:26:15 UTC,
py,
verify,
result: Failed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
print (hasDominator)
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
The submission is being evaluated.
Code: 17:26:26 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
Code: 17:26:41 UTC,
py,
verify,
result: Failed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
print(count)
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
The submission is being evaluated.
Code: 17:26:57 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
Code: 17:27:07 UTC,
py,
verify,
result: Failed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] == A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
print(stack)
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
The submission is being evaluated.
Code: 17:27:33 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] != A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
print(stack)
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
Code: 17:27:35 UTC,
py,
verify,
result: Failed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] != A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
print(stack)
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
The submission is being evaluated.
Code: 17:28:02 UTC,
py,
verify,
result: Failed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] != A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
print(hasDominator)
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
The submission is being evaluated.
Code: 17:28:09 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] != A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
print(hasDominator)
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
Code: 17:28:27 UTC,
py,
verify,
result: Failed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] != A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
print(hasDominator)
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
print(prefixSum)
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
The submission is being evaluated.
Code: 17:28:39 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] != A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
print(hasDominator)
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
else
print(prefixSum)
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
Code: 17:28:58 UTC,
py,
verify,
result: Failed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] != A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
print(hasDominator)
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
print(prefixSum)
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
The submission is being evaluated.
Code: 17:31:49 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] != A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
print(hasDominator)
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
print(prefixSum)
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
Code: 17:32:18 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] != A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
print(hasDominator)
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
print(prefixSum)
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
print(prefixSum[i])
print(prefixSum[length-1]-prefixSum[i])
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
Code: 17:32:46 UTC,
py,
verify,
result: Failed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] != A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
print(hasDominator)
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
print(prefixSum)
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
print(prefixSum[i])
print(prefixSum[length-1]-prefixSum[i])
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
The submission is being evaluated.
Code: 17:33:13 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] != A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
print(hasDominator)
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
print(prefixSum)
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
print(prefixSum[i] )
print(prefixSum[length-1]-prefixSum[i])
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
Code: 17:33:39 UTC,
py,
verify,
result: Failed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] != A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
print(hasDominator)
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
print(prefixSum)
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
print(prefixSum[i] + " " + (i+1)/2)
print(prefixSum[length-1]-prefixSum[i] + " "+ (length-i)/2)
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
The submission is being evaluated.
Code: 17:36:45 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] != A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
print(hasDominator)
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
print(prefixSum)
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
print(prefixSum[i] " " + (i+1)/2)
print(prefixSum[length-1]-prefixSum[i] + " "+ (length-i)/2)
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
Code: 17:36:59 UTC,
py,
verify,
result: Failed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] != A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
print(hasDominator)
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
print(prefixSum)
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
print(prefixSum[i], " ", (i+1)/2)
print(prefixSum[length-1]-prefixSum[i], " ", (length-i)/2)
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
The submission is being evaluated.
Code: 17:37:13 UTC,
py,
verify,
result: Failed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] != A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
print(hasDominator)
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
print(prefixSum)
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
print(prefixSum[i], " ", (i+1)/2)
print(prefixSum[length-1]-prefixSum[i], " ", (length-i-1)/2)
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i)/2:
ans += 1
return ans
The submission is being evaluated.
Code: 17:37:27 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] != A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
print(hasDominator)
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
print(prefixSum)
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
print(prefixSum[i], " ", (i+1)/2)
print(prefixSum[length-1]-prefixSum[i], " ", (length-i-1)/2)
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i-1)/2:
ans += 1
return ans
Code: 17:37:28 UTC,
py,
verify,
result: Passed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] != A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
print(hasDominator)
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
print(prefixSum)
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
print(prefixSum[i], " ", (i+1)/2)
print(prefixSum[length-1]-prefixSum[i], " ", (length-i-1)/2)
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i-1)/2:
ans += 1
return ans
The submission is being evaluated.
Code: 17:37:39 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] != A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
print(hasDominator)
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
print(prefixSum)
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
# print(prefixSum[i], " ", (i+1)/2)
# print(prefixSum[length-1]-prefixSum[i], " ", (length-i-1)/2)
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i-1)/2:
ans += 1
return ans
Code: 17:37:52 UTC,
py,
verify,
result: Passed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] != A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
# print(hasDominator)
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# print(prefixSum)
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
# print(prefixSum[i], " ", (i+1)/2)
# print(prefixSum[length-1]-prefixSum[i], " ", (length-i-1)/2)
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i-1)/2:
ans += 1
return ans
The submission is being evaluated.
Code: 17:41:09 UTC,
py,
verify,
result: Passed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] != A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
# print(hasDominator)
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# print(prefixSum)
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
# print(prefixSum[i], " ", (i+1)/2)
# print(prefixSum[length-1]-prefixSum[i], " ", (length-i-1)/2)
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i-1)/2:
ans += 1
return ans
The submission is being evaluated.
Code: 17:41:11 UTC,
py,
final,
score: 
100
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# check if A has a dominator
length = len(A)
stack = [0]*length
size = 0
for i in range(length):
if size == 0:
stack[size] = A[i]
size += 1
elif stack[size-1] != A[i]:
size -=1
else:
stack[size] = A[i]
size += 1
count = 0
for i in range(length):
if A[i] == stack[size-1]:
count += 1
hasDominator = 0
if count > length/2:
hasDominator = 1
else:
return 0
# print(hasDominator)
# if A has a dominator -> prefix sum each index of doiminator numbers
prefixSum = [0]*length
curSum = 0
for i in range(length):
if A[i] == stack[size-1]:
curSum += 1
prefixSum[i] = curSum
# print(prefixSum)
# final step find all the cuts points that makes equiDominator happen
ans = 0
for i in range(length):
# print(prefixSum[i], " ", (i+1)/2)
# print(prefixSum[length-1]-prefixSum[i], " ", (length-i-1)/2)
if prefixSum[i] > (i+1)/2 and prefixSum[length-1]-prefixSum[i] > (length-i-1)/2:
ans += 1
return ans
The submission is being evaluated.