Java Python Lists
Category: Linked Lists & Stacks
This guide covers five popular interview questions in both Java and Python.
Reverse List
Overview
Reverse List is one of the most frequently asked coding interview questions.
Algorithm
Pointer reversal.
Complexity: O(n)
Tip: Iterative solution.
Python
class Solution:
def solve(self,*args):
# TODO: implement Reverse List
pass
Java
class Solution {
// TODO: implement Reverse List
}
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Merge Lists
Overview
Merge Lists is one of the most frequently asked coding interview questions.
Algorithm
Merge nodes.
Complexity: O(n)
Tip: Dummy head.
Python
class Solution:
def solve(self,*args):
# TODO: implement Merge Lists
pass
Java
class Solution {
// TODO: implement Merge Lists
}
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Valid Parentheses
Overview
Valid Parentheses is one of the most frequently asked coding interview questions.
Algorithm
Stack.
Complexity: O(n)
Tip: Push opening brackets.
Python
class Solution:
def solve(self,*args):
# TODO: implement Valid Parentheses
pass
Java
class Solution {
// TODO: implement Valid Parentheses
}
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Min Stack
Overview
Min Stack is one of the most frequently asked coding interview questions.
Algorithm
Track minimum.
Complexity: O(1)
Tip: Maintain second stack.
Python
class Solution:
def solve(self,*args):
# TODO: implement Min Stack
pass
Java
class Solution {
// TODO: implement Min Stack
}
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Remove Nth Node
Overview
Remove Nth Node is one of the most frequently asked coding interview questions.
Algorithm
Two pointers.
Complexity: O(n)
Tip: Fast/slow pointers.
Python
class Solution:
def solve(self,*args):
# TODO: implement Remove Nth Node
pass
Java
class Solution {
// TODO: implement Remove Nth Node
}
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.
Interview advice: explain your approach before coding, discuss edge cases, analyse time and
space complexity, and test your solution using small examples. Practising this problem
repeatedly improves pattern recognition.