mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-03-13 09:50:19 +08:00
improved prime numbers implementation (#1606)
* improved prime numbers implementation
* fixup! Format Python code with psf/black push
* fix type hint
* fixup! Format Python code with psf/black push
* fix doctests
* updating DIRECTORY.md
* added prime tests with negative numbers
* using for instead filter
* updating DIRECTORY.md
* Remove unused typing.List
* Remove tab indentation
* print("Sorted order is:", " ".join(a))
This commit is contained in:
committed by
Christian Clauss
parent
ccc1ff2ce8
commit
938dd0bbb5
@@ -30,7 +30,8 @@ class Heap(object):
|
||||
"""Performs changes required for swapping two elements in the heap"""
|
||||
# First update the indexes of the items in index map.
|
||||
self.pos_map[self.arr[i][0]], self.pos_map[self.arr[j][0]] = (
|
||||
self.pos_map[self.arr[j][0]], self.pos_map[self.arr[i][0]]
|
||||
self.pos_map[self.arr[j][0]],
|
||||
self.pos_map[self.arr[i][0]],
|
||||
)
|
||||
# Then swap the items in the list.
|
||||
self.arr[i], self.arr[j] = self.arr[j], self.arr[i]
|
||||
|
||||
Reference in New Issue
Block a user