ML coding, PyTorch & DSA interview questions.
Prepare for general coding plus ML-specific implementation work: tensors, training loops, attention, loss functions, batching, and debugging.
Serialize and Deserialize Binary TreePython & DSA · hard · Evidence 80/100Partition into K equal-sum subsetsPython & DSA · hard · Evidence 77/100Implement an in-place sorting algorithm and analyze every loop.Python & DSA · medium · Evidence 77/100Solve the maximum-points-on-a-line problem.Python & DSA · hard · Evidence 77/100Count and SayPython & DSA · medium · Evidence 77/100K Closest Points to OriginPython & DSA · medium · Evidence 77/100Validate a NumberPython & DSA · medium · Evidence 77/100Logger Timer With Additional ConstraintsPython & DSA · medium · Evidence 77/100Simplify a Relative PathPython & DSA · medium · Evidence 77/100Add/Subtract Operators to Reach a TargetPython & DSA · hard · Evidence 77/100Remove Invalid ParenthesesPython & DSA · hard · Evidence 77/100Robot Cleaner: Find the CheesePython & DSA · hard · Evidence 77/1003SumPython & DSA · medium · Evidence 77/100Sliding Window AveragePython & DSA · easy · Evidence 77/100Solve a variation of Longest Increasing Path in a Matrix.Python & DSA · hard · Evidence 77/100Tree DiameterPython & DSA · medium · Evidence 77/100Random pick with weightPython & DSA · medium · Evidence 77/100Optimize a Grid Computation From O(n²) to O(n)Python & DSA · hard · Evidence 77/100Valid Word AbbreviationPython & DSA · easy · Evidence 77/100Basic Calculator With + and *Python & DSA · medium · Evidence 77/100Second Greatest Number From DigitsPython & DSA · medium · Evidence 77/100Subarray Sum Equals KPython & DSA · medium · Evidence 77/100Next Greater ElementPython & DSA · medium · Evidence 77/100Moving average from a data streamPython & DSA · easy · Evidence 77/100Solve merge intervals.Python & DSA · medium · Evidence 77/100Count Monotonic RunsPython & DSA · medium · Evidence 77/100Lowest Common Ancestor of a Binary TreePython & DSA · medium · Evidence 77/100LRU Cache With Delete and LastPython & DSA · medium · Evidence 77/100Binary Tree Vertical Order TraversalPython & DSA · medium · Evidence 77/100Add Decimal Numbers as StringsPython & DSA · medium · Evidence 77/100Palindrome PermutationPython & DSA · easy · Evidence 77/100Implement Byte Pair Encoding.ML Coding & PyTorch · hard · Evidence 77/100Sample From a Non-Uniform RNGML Coding & PyTorch · hard · Evidence 77/100Design an efficient sparse-matrix representation.ML Coding & PyTorch · medium · Evidence 77/100Implement self-attention.ML Coding & PyTorch · hard · Evidence 77/100Implement rejection samplingML Coding & PyTorch · medium · Evidence 77/100Implement masked self-attention.ML Coding & PyTorch · hard · Evidence 77/100Implement the transpose of a sparse matrix efficiently.ML Coding & PyTorch · medium · Evidence 77/100How would you vectorize a K-means implementation?ML Coding & PyTorch · hard · Evidence 77/100Implement K-means from scratch.ML Coding & PyTorch · medium · Evidence 77/100Find and print a path from a source to a destination through obstacles.Python & DSA · medium · Evidence 75/100Implement MinStack with O(1) minimum lookup.Python & DSA · medium · Evidence 75/100How do you reason about time and space complexity in ML-adjacent coding?Python & DSA · medium · Evidence 75/100Generate valid word combinations from a word list.Python & DSA · medium · Evidence 75/100Solve a backtracking problem and explain pruning.Python & DSA · medium · Evidence 75/100Implement single-head attention in PyTorch.ML Coding & PyTorch · hard · Evidence 75/100Implement KL divergence in Python.ML Coding & PyTorch · medium · Evidence 75/100Add a causal mask that hides future tokens.ML Coding & PyTorch · hard · Evidence 75/100Implement self-attention from scratch in code.ML Coding & PyTorch · hard · Evidence 75/100Implement multi-head attention in PyTorch.ML Coding & PyTorch · hard · Evidence 75/100Find the Kth largest element in an array.Python & DSA · medium · Evidence 70/100Find the maximum number of consecutive ones in a binary array.Python & DSA · easy · Evidence 70/100Find the maximum water level that still permits a path from start to end.Python & DSA · hard · Evidence 70/100Navigate a mouse to cheese using only an API that tells whether a move is valid.Python & DSA · hard · Evidence 70/100Search in Rotated Sorted ArrayPython & DSA · medium · Evidence 66/100Binary Tree Maximum Path SumPython & DSA · hard · Evidence 66/100Implement a Categorical SamplerML Coding & PyTorch · medium · Evidence 66/100Implement Cross-Entropy Loss From ScratchML Coding & PyTorch · medium · Evidence 41/100Large-Scale Weighted Random SamplingML Coding & PyTorch · hard · Evidence 41/100Implement a Contrastive Learning LossML Coding & PyTorch · hard · Evidence 41/100Transformation + Sorting AI Coding ProblemML Coding & PyTorch · medium · Evidence 41/100How would you reduce memory movement in a custom CUDA inference kernel?ML Coding & PyTorch · hard · Evidence 41/100What bottlenecks would you optimize in a CUDA kernel used for model inference?ML Coding & PyTorch · hard · Evidence 41/100How would you optimize a deep-learning operation for GPU execution?ML Coding & PyTorch · hard · Evidence 40/100How do CPU and GPU architecture change ML data movement?ML Coding & PyTorch · hard · Evidence 40/100Implement and Optimize a Custom Neural Network LayerML Coding & PyTorch · hard · Evidence 34/100Implement a Transformer BlockML Coding & PyTorch · hard · Evidence 34/100Code Multi-Head Self-AttentionML Coding & PyTorch · hard · Evidence 34/100Implement a Transformer encoder layerML Coding & PyTorch · medium · Evidence 31/100