Giter Club home page Giter Club logo

devamoghs / python-interview-problems-for-practice Goto Github PK

View Code? Open in Web Editor NEW
966.0 33.0 151.0 723 KB

120+ Common code and interview problems solved in Python **(it's GROWING...)** Give a Star ๐ŸŒŸIf it helps you. Please go through the README.md before starting.

License: MIT License

Python 28.91% Jupyter Notebook 71.09%
interview-questions interview-preparation python-3 interview-prep python programming-interviews algotithms data-structures data-structures-and-algorithms interviews

python-interview-problems-for-practice's People

Contributors

devamoghs avatar luiz-surian avatar mangeshacs avatar rhthomas avatar rishitc avatar sameirquotb avatar syeedhasan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-interview-problems-for-practice's Issues

Formatting guidelines with Black

In the readme it says:

It passes style checks (PEP8 compliant) [TODO]

Would it be better to auto format all files with Black? This means dev's won't need to manually check for PEP8 compliance.

Inefficient BST_nodes_in_range.py

If using greater than or equal too and less than or equal to in line 14, then you can remove the check to see if it is ever equal to the max or the low range. So you can remove the lines 16 and 17.

union_array.py is not O(m+n) but O(m*n)

Problem: Given two sorted array of sizes m and n

in which all elements are distinct. Find the

union between them

Constraints: in O(m+n) complexity.

def unionArrays(x, y, m, n):
union_arr = []

for i in range(m):
union_arr.append(x[i])

for j in range(n):
if y[j] not in union_arr: # this lookup takes O(m) time in every call
union_arr.append(y[j])

print(union_arr)
return

list_a = [1, 2, 3, 4, 5]
list_b = [2, 3, 5, 6]
unionArrays(list_a, list_b, len(list_a), len(list_b))

Syntax error in ./preorder_iterative_bst.py

flake8 testing of https://github.com/devAmoghS/Python-Interview-Problems-for-Practice on Python 3.7.1

$ flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics

./preorder_iterative_bst.py:9:47: E999 SyntaxError: invalid syntax
    stack.insert(0, right) if right is not None
                                              ^
./loop_in_linkedlist.py:17:15: F821 undefined name 'LinkedList'
linked_list = LinkedList()
              ^
./loop_in_linkedlist.py:19:7: F821 undefined name 'findMToLast'
print(findMToLast(linked_list))
      ^
./remove_duplicates_v2.py:10:10: F821 undefined name 'remove_duplicates'
result = remove_duplicates([0,0,0,1,1,2,2,3,4,5])
         ^
./find_m_to_last_llist.py:21:15: F821 undefined name 'LinkedList'
linked_list = LinkedList()
              ^
./dfs_bfs.py:20:9: F821 undefined name 'dfs'
        dfs(graph, next, visited)
        ^
./heap_structure.py:68:14: F821 undefined name 'self'
    result = self.heap[0]
             ^
./heap_structure.py:69:5: F821 undefined name 'self'
    self.currentPosition-=1
    ^
./heap_structure.py:70:5: F821 undefined name 'self'
    self.heap[0] = self.heap[self.currentPosition]
    ^
./heap_structure.py:70:20: F821 undefined name 'self'
    self.heap[0] = self.heap[self.currentPosition]
                   ^
./heap_structure.py:70:30: F821 undefined name 'self'
    self.heap[0] = self.heap[self.currentPosition]
                             ^
./heap_structure.py:71:9: F821 undefined name 'self'
    del self.heap[self.currentPosition]
        ^
./heap_structure.py:71:19: F821 undefined name 'self'
    del self.heap[self.currentPosition]
                  ^
./heap_structure.py:72:5: F821 undefined name 'self'
    self.fixDown(0, -1)
    ^
1     E999 SyntaxError: invalid syntax
13    F821 undefined name 'dfs'
14

E901,E999,F821,F822,F823 are the "showstopper" flake8 issues that can halt the runtime with a SyntaxError, NameError, etc. These 5 are different from most other flake8 issues which are merely "style violations" -- useful for readability but they do not effect runtime safety.

  • F821: undefined name name
  • F822: undefined name name in __all__
  • F823: local variable name referenced before assignment
  • E901: SyntaxError or IndentationError
  • E999: SyntaxError -- failed to compile a file into an Abstract Syntax Tree

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.