Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 10815b3

Browse files
committed
Imported LinkedList data structure
1 parent 13bbed8 commit 10815b3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

‎find_m_to_last_llist.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,23 @@
33
# 2->3->4->8->5; m=2 will return 8
44
# since 8 is second to last
55

6+
from linked_list_data_structure import LinkedList
7+
68
def findMToLast(l_list, m):
79
current = l_list.head
810
count = 0
9-
11+
1012
while current is not None and count < m:
1113
count+=1
1214
current = current.getNextNode()
13-
15+
1416
m_behind = l_list.head
1517
while current.next_node is not None:
1618
current = current.getNextNode()
1719
m_behind = m_behind.getNextNode()
18-
20+
1921
return m_behind
20-
22+
2123
linked_list = LinkedList()
2224
m_to_last = 3
2325
# Returns the third element from last

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /