Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions python_implemented/kadanes_algorithm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from sys import maxsize

def maxSubArraySum(a, size):
max_so_far = -maxsize - 1
max_ending_here = 0
start = 0
end = 0
s = 0

for i in range(0, size):

max_ending_here += a[i]

if max_so_far < max_ending_here:
max_so_far = max_ending_here
start = s
end = i

if max_ending_here < 0:
max_ending_here = 0
s = i + 1

print ("Maximum contiguous sum is %d" % (max_so_far))
print ("Starting Index %d" % (start))
print ("Ending Index %d" % (end))


# Driver program to test maxSubArraySum
a = [-2, -3, 4, -1, -2, 1, 5, -3]
maxSubArraySum(a, len(a))
31 changes: 31 additions & 0 deletions python_implemented/pangram_checking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# A Python Program to check if the given
# string is a pangram or not
def checkPangram(s):
List = []
# create list of 26 charecters and set false each entry
for i in range(26):
List.append(False)

# converting the sentence to lowercase and iterating
# over the sentence
for c in s.lower():
if not c == " ":
# make the corresponding entry True
List[ord(c) - ord('a')] = True

# check if any charecter is missing then return False
for ch in List:
if ch == False:
return False
return True


# Driver Program to test above functions
sentence = "The quick brown fox jumps over the little lazy dog"

if (checkPangram(sentence)):
print '"' + sentence + '"'
print "is a pangram"
else:
print '"' + sentence + '"'
print "is not a pangram"