Skip to content

Commit 0b4b76a

Browse files
authored
Add files via upload
1 parent db68b75 commit 0b4b76a

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

gagana/check.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
def is_sort(arr):
3+
for i in range(len(arr) - 1):
4+
if arr[i] > arr[i + 1]:
5+
return False
6+
return True
7+
arr = [1, 2, 3, 4, 5]
8+
print( is_sort(arr))
9+
arr = [5, 3, 4, 1, 2]
10+
print( is_sort(arr))
11+
12+
#O(n)
13+

gagana/occ.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def count_occurrences(arr, target):
2+
count = 0
3+
for element in arr:
4+
if element == target:
5+
count += 1
6+
return count
7+
arr = [1, 2, 3, 4, 5, 3, 3, 3,4,3]
8+
target = 3
9+
print(f"Occurrences of {target}:", count_occurrences(arr, target))
10+
# O(n)

0 commit comments

Comments
 (0)