Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowplane13 committed Jan 9, 2021
1 parent e169fee commit d053aed
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 27 deletions.
39 changes: 27 additions & 12 deletions convertInputToList.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
# FIRST METHOD
arr = []
for i in range(int(input('enter the size of array:'))):
arr.append(int(input()))
print (arr)
print (type(arr))

# SECOND METHOD
n = int(input("enter size of array"))
arr = list(map(int, input().split()))
print(type(arr))
print(arr)
# # FIRST METHOD
# arr = []
# for i in range(int(input('enter the size of array:'))):
# arr.append(int(input()))
# print (arr)
# print (type(arr))

# # SECOND METHOD
# n = int(input("enter size of array"))
# arr = list(map(int, input().split()))
# print(type(arr))
# print(arr)

# # THIRD METHOD
# n = int(input("enter size of array"))
# arr = list(map(int, input().split()))

import os
try:

my_home = os.environ['MY_HOME']
print(my_home)
except KeyError:
print("It doesn't exist")

curr = os.getcwd
print(curr)
14 changes: 14 additions & 0 deletions moveZeros.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# leetcode #283 easy
class Solution:
def moveZeroes(self, nums: List[int]) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
c = 0
for num in nums:
if (num != 0):
c += 1
else:
nums.remove(num)
nums.append(0)
print(nums)
30 changes: 15 additions & 15 deletions slidingWindow.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import sys
# print (sys.argv)

n = int(input("enter size of array"))
arr = list(map(int, input().split()))
print(type(arr))
print(arr)

#arr = [80, -50, 90, 100]
#n = 4
k = 2
maxSum = -0.0001
for i in range(0,n-k+1):
sumC = 0
for j in range(0,k):
sumC += arr[i+j]
#print(sumC)
maxSum = max(maxSum, sumC)
print(maxSum)

def calcMaxSum(arr,n):
k = 2
maxSum = -0.0001
for i in range(0, n-k+1):
sumC = 0
for j in range(0, k):
sumC += arr[i+j]
maxSum = max(maxSum, sumC)
return maxSum


ans = calcMaxSum(arr,n)
print(ans)

0 comments on commit d053aed

Please sign in to comment.