You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Singly Liked List
Append - Add the Node from end of the list
Prepend - Add the Node from front of the list
02. Singly Linked Lists -- Length of List
Singly Linked Lists -- Length of List
It will return the length of the Singly Linked List
Example:
Singly Linked List:
"A"
"B"
"C"
"D"
length of Singly Linked List is : 4
03. Singly Linked Lists -- Node Swap
Singly Linked Lists -- Node Swap
It will swap the node from Singly Linked List
Singly Linked Lists -- Reverse
It will reversed the Singly Linked List
Example:
"A""B""C""D""E"
reversed_list :"E""D""C""B""A"
Given the head of a singly linked list, reverse the list, and return the reversed list.
Example 1:
Input: head = [1,2,3,4,5]
Output: [5,4,3,2,1]
Example 2:
Input: head = [1,2]
Output: [2,1]
Example 3:
Input: head = []
Output: []
05. Singly Linked Lists -- Merge Two Sorted Lists
Singly Linked Lists -- Merge Two Sorted Lists
It will merge the two list in sorted order
Example:
Singly Linked List :
1
5
7
8
10
another Singly Linked List:
2
3
4
6
9
merge_list:
1
2
3
4
5
6
7
8
9
10
06. Singly Linked Lists -- Remove Duplicates
Singly Linked Lists -- Remove Duplicates
It will remove the duplicate Node from the Singly Linked List
Example:
1
2
7
2
1
7
1
After removing the duplicate Node from the Singly Linked list
Singly Linked List will be:
1
2
7
07. Singly Linked Lists -- Nth-to-Last Node
Singly Linked List -- Nth-to-Last Node
It will return the Node from last index number.
Example:
A
B
C
D
E
F
print_nth_from_last_method2(3):
D
08. Singly Linked Lists -- Count Occurrences
Singly Linked Lists -- Count Occurrences
It will return the number of Node present in the Singly Linked list of given Data.
Example:
1
1
2
3
1
4
1
2
count_occurences_iterative(1):
4
because 4 occurences of Node with data (1) available in the Singly Linked List
09. Singly Linked Lists -- Rotate
Singly Linked Lists -- Rotate
It will rotate the Singly linked List of given index number.
Example:
1
2
3
4
5
6
7
8
rotate_list(4):
5
6
7
8
1
2
3
4
10. Singly Linked Lists -- Is Palindrome
Singly Linked Lists -- Is Palindrome
A palindrome is a word or phrase that is the same forward and backwards.
Example:
R
A
C
E
C
A
R
RACEDAR can be same when read forward and backwards so this will return True.
Example:
H
E
L
L
O
HELLO cannot be read be same when read forward and backwards so this will return False.
11. Singly Linked Lists -- Move Tail to Head
Singly Linked Lists -- Move Tail to Head
It will move the last node to head of the Singly Linked list.
Example - singly LL is :
A
B
C
D
E
F
Ater move tail to head :
F
A
B
C
D
E
12. Singly Linked Lists -- Sum Two Lists
Singly Linked Lists -- Sum Two Lists
llist 1 :
3
6
5
and
llist 2 :
2
4
8
365 + 248 = 613