TikTok Machine Learning Engineer Coding & Algorithms Interview Questions
Master your tech interview with our curated database of real questions from top companies.
Count subarrays summing to target
Question LeetCode 560. Subarray Sum Equals K – Given an integer array nums and an integer k, return the total number of continuous subarrays whose sum...
Compute longest increasing subsequence
Given an integer array nums, compute the length of a longest strictly increasing subsequence and also output one valid subsequence. Aim for an O(n log...
Determine frog reachability across stones
You are given a sorted array of distinct integers stones representing stone positions in a river, where stones[0] = 0. A frog starts on stone 0; its f...
Fix a BST with two misplaced keys
You are given the root of a binary search tree in which exactly two nodes’ keys were accidentally swapped. Restore the tree so that its in-order trave...
Differentiate virtual and pure virtual functions
In C++, what is the difference between a virtual function and a pure virtual function? Provide syntax examples, describe dynamic dispatch via the vtab...
Find second-minimal word segmentation count
Given a string s and a dictionary D of non-empty words, define a 'segmentation' as splitting s into a sequence of words from D whose concatenation equ...
Find and count target-sum subarrays
Given an integer array nums and an integer target, implement: ( 1) a function that returns true if any non-empty contiguous subarray sums to target; (...
Compute city skyline silhouette
Compute the outer silhouette of a 2D skyline. You are given n axis-aligned rectangular buildings; each building i is (Li, Ri, Hi) with 0 <= Li < Ri an...