-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e169fee
commit d053aed
Showing
3 changed files
with
56 additions
and
27 deletions.
There are no files selected for viewing
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
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) |
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
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) |
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
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) |