Skip to content

Commit c60ecc0

Browse files
authored
MinHeap Data Structure (#183)
* Migrate project to Justfile * Update Github action * Add min heap data structure * Format files
1 parent d2a8d43 commit c60ecc0

164 files changed

Lines changed: 541 additions & 425 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.devcontainer/Dockerfile‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.238.0/containers/python-3/.devcontainer/base.Dockerfile
22

33
# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster
4-
ARG VARIANT="3.10-bullseye"
4+
ARG VARIANT="3.14-bullseye"
55
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
66

7-
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
8-
ARG NODE_VERSION="none"
9-
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
10-
117
# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
128
# COPY requirements.txt /tmp/pip-tmp/
139
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \

‎.gitattributes‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.devcontainer/* -linguist-detectable
2+
.github/** -linguist-detectable

‎.github/workflows/Python.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
pip install -r requirements.txt
2727
- name: Lint
2828
run: |
29-
flake8 --max-complexity=10 --max-line-length=120 --statistics
29+
just lint
3030
- name: Unit tests
3131
run: |
32-
pytest
32+
just test

‎algorithm_theory/binary_search.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def binary_search_iterative(array: [int], target: int) -> Optional[int]:
2323

2424
def binary_search_recursive(array: [int], left: int, right: int, target: int) -> Optional[int]:
2525
if right >= left:
26-
2726
mid = int((left + right) / 2)
2827

2928
# If element is present at the middle

‎algorithm_theory/jump_search.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import math
77
from typing import Optional
8+
89
from algorithm_theory.linear_search import linear_search
910

1011

‎algorithm_theory/linear_search.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from typing import Optional
22

3-
43
# The most basic search. Start from the leftmost element of the array and one by one compare the target with each
54
# element of the array. If the target matches with an element, return the index.
65

‎arrays/arrays_intersection.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from typing import List
22

3-
43
# Leetcode 1213. Intersection of Three Sorted Arrays
54

5+
66
def arrays_intersection(arr1: List[int], arr2: List[int], arr3: List[int]) -> List[int]:
77
intersection = set(arr1)
88
intersection = intersection.intersection(arr2)

‎arrays/find_pivot_index.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
def find_pivot_index(nums: [int]) -> int:
32
total = sum(nums)
43
left_sum = 0

‎arrays/first_not_repeating_character.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ def first_not_repeating_character(string: str) -> str:
99
length = len(string)
1010
index = 0
1111
while index < length:
12-
if string[index] not in string[:index] and string[index] not in string[index + 1:]:
12+
if string[index] not in string[:index] and string[index] not in string[index + 1 :]:
1313
return string[index]
1414
index += 1
15-
return '_'
15+
return "_"
1616

1717

1818
def first_not_repeating_character_set(string: str) -> str:
@@ -21,4 +21,4 @@ def first_not_repeating_character_set(string: str) -> str:
2121
if char not in checked_characters and string.index(char) == string.rindex(char):
2222
return char
2323
checked_characters.add(char)
24-
return '_'
24+
return "_"

‎arrays/largest_number_at_least_twice_of_others.py‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
from typing import List
2+
3+
4+
def largest_number_at_least_twice_of_others(nums: List[int]) -> int:
5+
"""Find largest number that is atleast twice the size of any other number
16
2-
def largest_number_at_least_twice_of_others(nums: [int]) -> int:
3-
"""
4-
Find largest number that is atleast twice the size of any other number
57
:param nums: array of numbers
68
:return: index of number, -1 if none exists
9+
710
"""
811
largest = None
912
next_largest = None
@@ -25,10 +28,11 @@ def largest_number_at_least_twice_of_others(nums: [int]) -> int:
2528

2629

2730
def largest_number_at_least_twice_of_others2(nums: [int]) -> int:
28-
"""
29-
Find largest number that is atleast twice the size of any other number
31+
"""Find largest number that is atleast twice the size of any other number
32+
3033
:param nums: array of numbers
3134
:return: index of number, -1 if none exists
35+
3236
"""
3337
if len(nums) == 1:
3438
return 0

0 commit comments

Comments
 (0)