TikTok Software Engineer Interview Questions

Review this list of 28 TikTok software engineer interview questions and answers verified by hiring managers and candidates.
  • TikTok logoAsked at TikTok 

    " At low level: I would use two stacks: one for forward history and other for backward history. i go to tryexponent.com => this url will be stored in backward history stack. i go to google => again this url will be stored in backward history stack. i press back => data from backward history will be popped and put in to forward history stack. I press forward => data from forward history stack will be popped and put in to backward history tab. Also, whenever i go to any url,"

    Anubhav S. - " At low level: I would use two stacks: one for forward history and other for backward history. i go to tryexponent.com => this url will be stored in backward history stack. i go to google => again this url will be stored in backward history stack. i press back => data from backward history will be popped and put in to forward history stack. I press forward => data from forward history stack will be popped and put in to backward history tab. Also, whenever i go to any url,"See full answer

    Software Engineer
    System Design
    +1 more
  • TikTok logoAsked at TikTok 
    +15

    "We can use dictionary to store cache items so that our read / write operations will be O(1). Each time we read or update an existing record, we have to ensure the item is moved to the back of the cache. This will allow us to evict the first item in the cache whenever the cache is full and we need to add new records also making our eviction O(1) Instead of normal dictionary, we will use ordered dictionary to store cache items. This will allow us to efficiently move items to back of the cache a"

    Alfred O. - "We can use dictionary to store cache items so that our read / write operations will be O(1). Each time we read or update an existing record, we have to ensure the item is moved to the back of the cache. This will allow us to evict the first item in the cache whenever the cache is full and we need to add new records also making our eviction O(1) Instead of normal dictionary, we will use ordered dictionary to store cache items. This will allow us to efficiently move items to back of the cache a"See full answer

    Software Engineer
    Data Structures & Algorithms
    +5 more
  • +5

    "As a PM i received a feedback from my program manager on my style of verbal communication. It is about me speaking faster when i wanted to get away with a topic that i wasn't confident (may be not backed up with data, or still in process of getting detailed insight of a problem etc.). Whereas when I'm confident I tend to speak slowly or more assertively that made people to follow easily. I welcomed that feedback so from then on when I'm not confident in a topic I became more assertive to let pe"

    Rajesh V. - "As a PM i received a feedback from my program manager on my style of verbal communication. It is about me speaking faster when i wanted to get away with a topic that i wasn't confident (may be not backed up with data, or still in process of getting detailed insight of a problem etc.). Whereas when I'm confident I tend to speak slowly or more assertively that made people to follow easily. I welcomed that feedback so from then on when I'm not confident in a topic I became more assertive to let pe"See full answer

    Software Engineer
    Behavioral
    +6 more
  • TikTok logoAsked at TikTok 

    "Use a representative of each, e.g. sort the string and add it to the value of a hashmap> where we put all the words that belong to the same anagram together."

    Gaston B. - "Use a representative of each, e.g. sort the string and add it to the value of a hashmap> where we put all the words that belong to the same anagram together."See full answer

    Software Engineer
    Data Structures & Algorithms
    +4 more
  • TikTok logoAsked at TikTok 
    Video answer for 'Design a typeahead box for a search engine.'
    +5

    "It would have been more interesting to focus on the system design rather than the Trie DS, Interviewee could have just mentioned the Trie and passed to things more important. Interviewee should have focused on the factors on which he wants to scale the API servers, popularity of the query parts ? region may be ? A hash of many factors ? Caches should have definitely be discussed, Cache eviction policies, Cache invalidation managements... Interviewee should have mentioned which kind of API pro"

    Aymen D. - "It would have been more interesting to focus on the system design rather than the Trie DS, Interviewee could have just mentioned the Trie and passed to things more important. Interviewee should have focused on the factors on which he wants to scale the API servers, popularity of the query parts ? region may be ? A hash of many factors ? Caches should have definitely be discussed, Cache eviction policies, Cache invalidation managements... Interviewee should have mentioned which kind of API pro"See full answer

    Software Engineer
    System Design
    +1 more
  • 🧠 Want an expert answer to a question? Saving questions lets us know what content to make next.

  • TikTok logoAsked at TikTok 
    Video answer for 'Merge Intervals'
    +33

    "const mergeIntervals = (intervals) => { const compare = (a, b) => { if(a[0] b[0]) return 1 else if(a[0] === b[0]) { return a[1] - b[1] } } let current = [] const result = [] const sorted = intervals.sort(compare) for(let i = 0; i = b[0]) current[1] = b[1] els"

    Kofi N. - "const mergeIntervals = (intervals) => { const compare = (a, b) => { if(a[0] b[0]) return 1 else if(a[0] === b[0]) { return a[1] - b[1] } } let current = [] const result = [] const sorted = intervals.sort(compare) for(let i = 0; i = b[0]) current[1] = b[1] els"See full answer

    Software Engineer
    Data Structures & Algorithms
    +6 more
  • TikTok logoAsked at TikTok 
    +4

    "Any cycle would cause the prerequisite to be greater than the course. This passes all the tests: function canFinish(_numCourses, prerequisites) { for (const [a, b] of prerequisites) { if (b > a) return false } return true } `"

    Jeremy D. - "Any cycle would cause the prerequisite to be greater than the course. This passes all the tests: function canFinish(_numCourses, prerequisites) { for (const [a, b] of prerequisites) { if (b > a) return false } return true } `"See full answer

    Software Engineer
    Data Structures & Algorithms
    +4 more
  • TikTok logoAsked at TikTok 
    +14

    "function isValid(s) { const stack = []; for (let i=0; i < s.length; i++) { const char = s.charAt(i); if (['(', '{', '['].includes(char)) { stack.push(char); } else { const top = stack.pop(); if ((char === ')' && top !== '(') || (char === '}' && top !== '{') || (char === ']' && top !== '[')) { return false; } } } return stack.length === 0"

    Tiago R. - "function isValid(s) { const stack = []; for (let i=0; i < s.length; i++) { const char = s.charAt(i); if (['(', '{', '['].includes(char)) { stack.push(char); } else { const top = stack.pop(); if ((char === ')' && top !== '(') || (char === '}' && top !== '{') || (char === ']' && top !== '[')) { return false; } } } return stack.length === 0"See full answer

    Software Engineer
    Data Structures & Algorithms
    +4 more
  • TikTok logoAsked at TikTok 
    Video answer for 'Move all zeros to the end of an array.'
    +39

    "Initialize left pointer: Set a left pointer left to 0. Iterate through the array: Iterate through the array from left to right. If the current element is not 0, swap it with the element at the left pointer and increment left. Time complexity: O(n). The loop iterates through the entire array once, making it linear time. Space complexity: O(1). The algorithm operates in-place, modifying the input array directly without using additional data structures. "

    Avon T. - "Initialize left pointer: Set a left pointer left to 0. Iterate through the array: Iterate through the array from left to right. If the current element is not 0, swap it with the element at the left pointer and increment left. Time complexity: O(n). The loop iterates through the entire array once, making it linear time. Space complexity: O(1). The algorithm operates in-place, modifying the input array directly without using additional data structures. "See full answer

    Software Engineer
    Data Structures & Algorithms
    +4 more
  • TikTok logoAsked at TikTok 
    Video answer for 'Design a key-value store.'

    "Simple file system ( Hash Map , LSM trees), and consistent hashing. I failed to discuss about conflicts ( Versioning)"

    V V. - "Simple file system ( Hash Map , LSM trees), and consistent hashing. I failed to discuss about conflicts ( Versioning)"See full answer

    Software Engineer
    System Design
    +2 more
  • TikTok logoAsked at TikTok 
    Video answer for 'Given the root of a binary tree of integers, return the maximum path sum.'

    "\# Definition for a binary tree node. class TreeNode: def init(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def maxPathSum(self, root: TreeNode) -> int: self.max_sum = float('-inf')"

    Jerry O. - "\# Definition for a binary tree node. class TreeNode: def init(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def maxPathSum(self, root: TreeNode) -> int: self.max_sum = float('-inf')"See full answer

    Software Engineer
    Data Structures & Algorithms
    +4 more
  • TikTok logoAsked at TikTok 
    +8

    "public static Integer[] findLargest(int[] input, int m) { if(input==null || input.length==0) return null; PriorityQueue minHeap=new PriorityQueue(); for(int i:input) { if(minHeap.size()(int)top){ minHeap.poll(); minHeap.add(i); } } } Integer[] res=minHeap.toArray(new Integer[0]); Arrays.sort(res); return res; }"

    Divya R. - "public static Integer[] findLargest(int[] input, int m) { if(input==null || input.length==0) return null; PriorityQueue minHeap=new PriorityQueue(); for(int i:input) { if(minHeap.size()(int)top){ minHeap.poll(); minHeap.add(i); } } } Integer[] res=minHeap.toArray(new Integer[0]); Arrays.sort(res); return res; }"See full answer

    Software Engineer
    Data Structures & Algorithms
    +2 more
  • Software Engineer
    Data Structures & Algorithms
    +4 more
  • TikTok logoAsked at TikTok 

    "I aim to utilize hands-on activities to apply the knowledge I've acquired, safeguard the organization from threat actors, and contribute to its growth."

    Bravin V. - "I aim to utilize hands-on activities to apply the knowledge I've acquired, safeguard the organization from threat actors, and contribute to its growth."See full answer

    Software Engineer
    Behavioral
  • TikTok logoAsked at TikTok 
    Video answer for 'Given an nxn grid of 1s and 0s, return the number of islands in the input.'
    +9

    " from typing import List def getnumberof_islands(binaryMatrix: List[List[int]]) -> int: if not binaryMatrix: return 0 rows = len(binaryMatrix) cols = len(binaryMatrix[0]) islands = 0 for r in range(rows): for c in range(cols): if binaryMatrixr == 1: islands += 1 dfs(binaryMatrix, r, c) return islands def dfs(grid, r, c): if ( r = len(grid) "

    Rick E. - " from typing import List def getnumberof_islands(binaryMatrix: List[List[int]]) -> int: if not binaryMatrix: return 0 rows = len(binaryMatrix) cols = len(binaryMatrix[0]) islands = 0 for r in range(rows): for c in range(cols): if binaryMatrixr == 1: islands += 1 dfs(binaryMatrix, r, c) return islands def dfs(grid, r, c): if ( r = len(grid) "See full answer

    Software Engineer
    Data Structures & Algorithms
    +4 more
  • TikTok logoAsked at TikTok 
    +7

    "def find_primes(n): lst=[] for i in range(2,n+1): is_prime=1 for j in range(2,int(i**0.5)+1): if i%j==0: is_prime=0 break if is_prime: lst.append(i) return lst "

    Anonymous Raccoon - "def find_primes(n): lst=[] for i in range(2,n+1): is_prime=1 for j in range(2,int(i**0.5)+1): if i%j==0: is_prime=0 break if is_prime: lst.append(i) return lst "See full answer

    Software Engineer
    Data Structures & Algorithms
    +4 more
  • TikTok logoAsked at TikTok 
    Video answer for 'Find a triplet in an array with a given sum.'
    +5

    "from typing import List def three_sum(nums: List[int]) -> List[List[int]]: nums.sort() triplets = set() for i in range(len(nums) - 2): firstNum = nums[i] l = i + 1 r = len(nums) - 1 while l 0: r -= 1 elif potentialSum < 0: l += 1 "

    Anonymous Roadrunner - "from typing import List def three_sum(nums: List[int]) -> List[List[int]]: nums.sort() triplets = set() for i in range(len(nums) - 2): firstNum = nums[i] l = i + 1 r = len(nums) - 1 while l 0: r -= 1 elif potentialSum < 0: l += 1 "See full answer

    Software Engineer
    Data Structures & Algorithms
    +3 more
  • Software Engineer
    Data Structures & Algorithms
    +3 more
  • TikTok logoAsked at TikTok 
    Video answer for 'Given stock prices for the next n days, how can you maximize your profit by buying or selling one share per day?'
    +9

    "from typing import List def maxprofitgreedy(stock_prices: List[int]) -> int: l=0 # buying r=1 # selling max_profit=0 while rstock_prices[l]: profit=stockprices[r]-stockprices[l] maxprofit=max(maxprofit,profit) else: l=r r+=1 return max_profit debug your code below print(maxprofitgreedy([7, 1, 5, 3, 6, 4])) `"

    Prajwal M. - "from typing import List def maxprofitgreedy(stock_prices: List[int]) -> int: l=0 # buying r=1 # selling max_profit=0 while rstock_prices[l]: profit=stockprices[r]-stockprices[l] maxprofit=max(maxprofit,profit) else: l=r r+=1 return max_profit debug your code below print(maxprofitgreedy([7, 1, 5, 3, 6, 4])) `"See full answer

    Software Engineer
    Data Structures & Algorithms
    +4 more
  • TikTok logoAsked at TikTok 
    Software Engineer
    Data Structures & Algorithms
    +4 more
Showing 1-20 of 28