Skip to content

Commit 0889d74

Browse files
Initial
0 parents  commit 0889d74

File tree

118 files changed

+2064
-0
lines changed

Some content is hidden

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

118 files changed

+2064
-0
lines changed

.gitignore

Lines changed: 289 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,289 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/python,pycharm
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=python,pycharm
3+
4+
### PyCharm ###
5+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
6+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
7+
8+
# User-specific stuff
9+
.idea/**/workspace.xml
10+
.idea/**/tasks.xml
11+
.idea/**/usage.statistics.xml
12+
.idea/**/dictionaries
13+
.idea/**/shelf
14+
15+
# AWS User-specific
16+
.idea/**/aws.xml
17+
18+
# Generated files
19+
.idea/**/contentModel.xml
20+
21+
# Sensitive or high-churn files
22+
.idea/**/dataSources/
23+
.idea/**/dataSources.ids
24+
.idea/**/dataSources.local.xml
25+
.idea/**/sqlDataSources.xml
26+
.idea/**/dynamic.xml
27+
.idea/**/uiDesigner.xml
28+
.idea/**/dbnavigator.xml
29+
30+
# Gradle
31+
.idea/**/gradle.xml
32+
.idea/**/libraries
33+
34+
# Gradle and Maven with auto-import
35+
# When using Gradle or Maven with auto-import, you should exclude module files,
36+
# since they will be recreated, and may cause churn. Uncomment if using
37+
# auto-import.
38+
# .idea/artifacts
39+
# .idea/compiler.xml
40+
# .idea/jarRepositories.xml
41+
# .idea/modules.xml
42+
# .idea/*.iml
43+
# .idea/modules
44+
# *.iml
45+
# *.ipr
46+
47+
# CMake
48+
cmake-build-*/
49+
50+
# Mongo Explorer plugin
51+
.idea/**/mongoSettings.xml
52+
53+
# File-based project format
54+
*.iws
55+
56+
# IntelliJ
57+
out/
58+
59+
# mpeltonen/sbt-idea plugin
60+
.idea_modules/
61+
62+
# JIRA plugin
63+
atlassian-ide-plugin.xml
64+
65+
# Cursive Clojure plugin
66+
.idea/replstate.xml
67+
68+
# SonarLint plugin
69+
.idea/sonarlint/
70+
71+
# Crashlytics plugin (for Android Studio and IntelliJ)
72+
com_crashlytics_export_strings.xml
73+
crashlytics.properties
74+
crashlytics-build.properties
75+
fabric.properties
76+
77+
# Editor-based Rest Client
78+
.idea/httpRequests
79+
80+
# Android studio 3.1+ serialized cache file
81+
.idea/caches/build_file_checksums.ser
82+
83+
### PyCharm Patch ###
84+
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
85+
86+
# *.iml
87+
# modules.xml
88+
# .idea/misc.xml
89+
# *.ipr
90+
91+
# Sonarlint plugin
92+
# https://plugins.jetbrains.com/plugin/7973-sonarlint
93+
.idea/**/sonarlint/
94+
95+
# SonarQube Plugin
96+
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
97+
.idea/**/sonarIssues.xml
98+
99+
# Markdown Navigator plugin
100+
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
101+
.idea/**/markdown-navigator.xml
102+
.idea/**/markdown-navigator-enh.xml
103+
.idea/**/markdown-navigator/
104+
105+
# Cache file creation bug
106+
# See https://youtrack.jetbrains.com/issue/JBR-2257
107+
.idea/$CACHE_FILE$
108+
109+
# CodeStream plugin
110+
# https://plugins.jetbrains.com/plugin/12206-codestream
111+
.idea/codestream.xml
112+
113+
# Azure Toolkit for IntelliJ plugin
114+
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
115+
.idea/**/azureSettings.xml
116+
117+
### Python ###
118+
# Byte-compiled / optimized / DLL files
119+
__pycache__/
120+
*.py[cod]
121+
*$py.class
122+
123+
# C extensions
124+
*.so
125+
126+
# Distribution / packaging
127+
.Python
128+
build/
129+
develop-eggs/
130+
dist/
131+
downloads/
132+
eggs/
133+
.eggs/
134+
lib/
135+
lib64/
136+
parts/
137+
sdist/
138+
var/
139+
wheels/
140+
share/python-wheels/
141+
*.egg-info/
142+
.installed.cfg
143+
*.egg
144+
MANIFEST
145+
146+
# PyInstaller
147+
# Usually these files are written by a python script from a template
148+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
149+
*.manifest
150+
*.spec
151+
152+
# Installer logs
153+
pip-log.txt
154+
pip-delete-this-directory.txt
155+
156+
# Unit test / coverage reports
157+
htmlcov/
158+
.tox/
159+
.nox/
160+
.coverage
161+
.coverage.*
162+
.cache
163+
nosetests.xml
164+
coverage.xml
165+
*.cover
166+
*.py,cover
167+
.hypothesis/
168+
.pytest_cache/
169+
cover/
170+
171+
# Translations
172+
*.mo
173+
*.pot
174+
175+
# Django stuff:
176+
*.log
177+
local_settings.py
178+
db.sqlite3
179+
db.sqlite3-journal
180+
181+
# Flask stuff:
182+
instance/
183+
.webassets-cache
184+
185+
# Scrapy stuff:
186+
.scrapy
187+
188+
# Sphinx documentation
189+
docs/_build/
190+
191+
# PyBuilder
192+
.pybuilder/
193+
target/
194+
195+
# Jupyter Notebook
196+
.ipynb_checkpoints
197+
198+
# IPython
199+
profile_default/
200+
ipython_config.py
201+
202+
# pyenv
203+
# For a library or package, you might want to ignore these files since the code is
204+
# intended to run in multiple environments; otherwise, check them in:
205+
# .python-version
206+
207+
# pipenv
208+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
209+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
210+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
211+
# install all needed dependencies.
212+
#Pipfile.lock
213+
214+
# poetry
215+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
216+
# This is especially recommended for binary packages to ensure reproducibility, and is more
217+
# commonly ignored for libraries.
218+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
219+
#poetry.lock
220+
221+
# pdm
222+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
223+
#pdm.lock
224+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
225+
# in version control.
226+
# https://pdm.fming.dev/#use-with-ide
227+
.pdm.toml
228+
229+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
230+
__pypackages__/
231+
232+
# Celery stuff
233+
celerybeat-schedule
234+
celerybeat.pid
235+
236+
# SageMath parsed files
237+
*.sage.py
238+
239+
# Environments
240+
.env
241+
.venv
242+
env/
243+
venv/
244+
ENV/
245+
env.bak/
246+
venv.bak/
247+
248+
# Spyder project settings
249+
.spyderproject
250+
.spyproject
251+
252+
# Rope project settings
253+
.ropeproject
254+
255+
# mkdocs documentation
256+
/site
257+
258+
# mypy
259+
.mypy_cache/
260+
.dmypy.json
261+
dmypy.json
262+
263+
# Pyre type checker
264+
.pyre/
265+
266+
# pytype static type analyzer
267+
.pytype/
268+
269+
# Cython debug symbols
270+
cython_debug/
271+
272+
# PyCharm
273+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
274+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
275+
# and can be added to the global gitignore or merged into this file. For a more nuclear
276+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
277+
#.idea/
278+
279+
### Python Patch ###
280+
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
281+
poetry.toml
282+
283+
# ruff
284+
.ruff_cache/
285+
286+
# LSP config files
287+
pyrightconfig.json
288+
289+
# End of https://www.toptal.com/developers/gitignore/api/python,pycharm

.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/dsa.iml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

algorithms/sliding_window/__init__.py

Whitespace-only changes.

algorithms/two_pointers/__init__.py

Whitespace-only changes.

array/___init__.py

Whitespace-only changes.

array/problems/__init__.py

Whitespace-only changes.

array/problems/find_deleted_number.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
Given an array of numbers starting from 1 to n.
3+
Array is not sorted and some number was deleted. Find number that was deleted from array.
4+
5+
Considerations:
6+
0 < n > array.length + 1
7+
8+
1 - time complexity(n log n) space complexity (1)
9+
- sort array
10+
- iterate over array starting from the second element
11+
- if current element is greater that previous by more than 1 it means result is previous item + 1
12+
13+
2 - time complexity(n), space complexity(n)
14+
iterate over list and put all items into the set
15+
then iterate over number starting from 1 to array length + 1
16+
on every step check if number in set.
17+
if item is not in the set that it is the target
18+
19+
3 - subtract sum of elements in array with sum of math progression
20+
"""
21+
from mytypes import NumberArray
22+
23+
24+
def find_deleted_number(array: NumberArray) -> int:
25+
return ((len(array) + 1) * (len(array) + 2) // 2) - sum(array)
26+
27+
28+
assert find_deleted_number([1, 2, 4]) == 3
29+
assert find_deleted_number([])

0 commit comments

Comments
 (0)