Current Position: SDE-II
Current Company: Banking MNC
Experience: Python Developer with 4.5 years of experience
College: Tier-2
Online Assessment
HackerRank
Programming Questions: 3 questions focusing on Data Structures and Algorithms (DSA). Topics include dynamic programming, graphs, and tree DP.
Round 1: Data Structures and Algorithms (1 hour 15 min)
DSA Problem 1: Find all the articulation points in a graph.
DSA Problem 2: Partition an array into two subsets such that the absolute difference between the sums of the subsets is minimized.
problem 3:
class MyInt(int):
def __new__(cls, value):
print(f"Creating MyInt({value})")
return super().__new__(cls, value)
def __eq__(self, other):
print("Checking equality")
if isinstance(other, MyInt):
return super().__eq__(other) and self.real == other.real
return False
def __hash__(self):
print("Calculating hash")
return super().__hash__()
a = MyInt(10)
b = MyInt(10)
print(a == b)
print(hash(a) == hash(b))a == b return Falsehash(a) == hash(b) return TrueRound 2: Data Structures and Concepts
DSA Problem 1: What is Best-First Search? Questions on its properties and applications.
DSA Problem 2: What are the key properties of a (2,4) tree, and how do these properties impact the efficiency of search and insertion operations?
I mentioned that I had forgotten what a (2,4) tree was, and the interviewer briefly explained (in under 2 minutes) that a (2,4) tree is a type of self-balancing tree where each internal node has between 2 to 4 children, ensuring logarithmic search, insertion, and deletion times.
Follow-up Question: Write a function that inserts a key into a (2,4) tree, performing node splits and necessary rebalancing.
def insert_into_24_tree(tree: 'Node', key: int) -> 'Node':
"""
Inserts a key into a (2,4) tree and returns the new root node.
Parameters:
tree (Node): The root node of the (2,4) tree.
key (int): The key to insert.
Returns:
Node: The root node of the updated (2,4) tree.
"""Discussion:
Round 3: Technical Round
Algorithmic Proof: Prove the correctness of your implementation of a merge sort that minimizes the number of inversions. Discuss the invariant maintained at each recursive level of the algorithm.
Python Application: Write Python code to manage a priority queue efficiently, implementing insertions and extractions in O(log n) time.
Discussion:
Round 4: Managerial and Technical
Round 5: Techno-Managerial