Search a 2D matrix where each row and column is sorted.
Write an efficient algorithm that searches for a value target in an m x n integer matrix. Integers in each row are sorted, and the first integer of each row is greater than the last integer of the previous row.
Input: matrix = [[1,4],[2,5]], target = 20
Output: FALSE
Explanation:…
Lowest Common Ancestor on an N-ary Tree
Find the lowest common ancestor on an N-ary tree.
Input: root = [1,null,2,3,4], p = 2, q = 3
Output: 1
Explanation: Both nodes 2 and 3 are direct children of the root node 1, making 1 the lowest common ancestor.
LLM Interview Questions I have Been Preparing Recently
I’ve been preparing for LLM/GenAI interviews, and one thing I noticed is that the questions are moving beyond basic “What is a transformer?” type questions.
A few areas that seem especially important:
**LLM Fundamentals**
- Why do transformers use self-attention?
- What is the difference between encoder-only, decoder-only, and encoder-d…
Maximum Depth of an N-ary Tree
Find the maximum depth of an N-ary tree.
Input: root = [1,null,2,null,3,null,4]
Output: 4
Explanation: The tree is essentially a straight line, requiring a traversal that reaches a maximum depth of 4 layers.