Created
March 4, 2019 03:00
-
-
Save rpf5573/95650bf434a29a3c3be51b32de3465f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
def solution(left, right): | |
total = 0 | |
indexOfLeft = 0 | |
indexOfRight = 0 | |
lengthOfLeft = len(left) | |
lengthOfRight = len(right) | |
while( (lengthOfLeft != indexOfLeft) and (lengthOfRight != indexOfRight) ): | |
l = left[indexOfLeft] | |
r = right[indexOfRight] | |
if l > r : | |
total = total + r | |
indexOfRight = indexOfRight + 1 | |
continue | |
if l <= r : | |
additionalIndex = 0 | |
for i in range(indexOfLeft+1, lengthOfLeft): | |
l = left[i] | |
if l > r : | |
additionalIndex = additionalIndex + 1 | |
break | |
if additionalIndex > 0 : | |
indexOfLeft = indexOfLeft + additionalIndex | |
else : | |
indexOfLeft = indexOfLeft + 1 | |
indexOfRight = indexOfRight + 1 | |
continue | |
return total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment