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
def randomMod(A, B, X1, K, M): | |
if K == 0 or M == 0: | |
print 'Input Error' | |
return | |
addAux = aux(A, K, B) | |
output = [0,0,0,0,0] | |
output[0] = (A**(K-1))*X1 + addAux |
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
class Solution: | |
# @param num, a list of integer | |
# @return a list of integer | |
def nextPermutation(self, num): | |
n = len(num) | |
k = -1 | |
l = -1 | |
# Find the largest k such that num[k] < num[k + 1] | |
for i in range(n - 1): | |
if num[i] < num[i + 1]: |
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
class Solution: | |
# @param A, a list of integers | |
# @return an integer | |
def maxSubArray(self, A): | |
ThisSum = 0 | |
MaxSum = -10000 | |
for i in range(0, len(A)): | |
if ThisSum < 0: | |
ThisSum = 0 |