Coding Interview Questions

Review this list of 363 coding interview questions and answers verified by hiring managers and candidates.
  • "/* You are with your friends in a castle, where there are multiple rooms named after flowers. Some of the rooms contain treasures - we call them the treasure rooms. Each room contains a single instruction that tells you which room to go to next. * instructions1 and treasurerooms_1 * lily* --------- daisy sunflower | | | v v v jasmin --> tulip* violet* ----> rose* --> ^ | ^ ^ | "

    Azeezat R. - "/* You are with your friends in a castle, where there are multiple rooms named after flowers. Some of the rooms contain treasures - we call them the treasure rooms. Each room contains a single instruction that tells you which room to go to next. * instructions1 and treasurerooms_1 * lily* --------- daisy sunflower | | | v v v jasmin --> tulip* violet* ----> rose* --> ^ | ^ ^ | "See full answer

    Software Engineer
    Coding
    +1 more
  • Microsoft logoAsked at Microsoft 
    +1

    "#simple solution 1.firstly find the node in the bst (O(logn) time complexity it take) 2.now removing the node consists of 3 cases: 1.if the node is leaf (no children): (keep track of parent and do) parent.left or parent.right=NULL simply remove the node () 2.if(has one child) replace the node with its child 3.if has both childs we replace the node with either inorder predesor(max of left tree)or inorder succesor and remove the node wh"

    Sambangi C. - "#simple solution 1.firstly find the node in the bst (O(logn) time complexity it take) 2.now removing the node consists of 3 cases: 1.if the node is leaf (no children): (keep track of parent and do) parent.left or parent.right=NULL simply remove the node () 2.if(has one child) replace the node with its child 3.if has both childs we replace the node with either inorder predesor(max of left tree)or inorder succesor and remove the node wh"See full answer

    Software Engineer
    Coding
  • +10

    "Would be better to adjust resolution in the video player directly."

    Anonymous Prawn - "Would be better to adjust resolution in the video player directly."See full answer

    Software Engineer
    Coding
    +4 more
  • "Use Dutch National Flag Algorithm to solve the problem"

    Sireesha R. - "Use Dutch National Flag Algorithm to solve the problem"See full answer

    Software Engineer
    Coding
    +1 more
  • Adobe logoAsked at Adobe 

    "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
    Coding
    +4 more
  • 🧠 Want an expert answer to a question? Saving questions lets us know what content to make next.

  • +24

    "SELECT d.name as departmentname,e.id as employeeid,e.firstname,e.lastname,MAX(e.salary) as salary FROM employees e LEFT JOIN departments d ON e.department_id=d.id GROUP BY department_name ORDER BY department_name;"

    Anisha S. - "SELECT d.name as departmentname,e.id as employeeid,e.firstname,e.lastname,MAX(e.salary) as salary FROM employees e LEFT JOIN departments d ON e.department_id=d.id GROUP BY department_name ORDER BY department_name;"See full answer

    Coding
    SQL
  • Atlassian logoAsked at Atlassian 
    Video answer for 'How would you store a list of numbers as a single number?'
    +7

    "First thing the interviewee did wrong is not asking clarifying questions. This is the most vague problem I have every heard, and the interviewee just made assumptions and started programming."

    Nicholas S. - "First thing the interviewee did wrong is not asking clarifying questions. This is the most vague problem I have every heard, and the interviewee just made assumptions and started programming."See full answer

    Engineering Manager
    Coding
    +2 more
  • Apple logoAsked at Apple 
    +10

    "we can use two pointer + set like maintain i,j and also insert jth character to set like while set size is equal to our window j-i+1 then maximize our answer and increase jth pointer till last index"

    Kishor J. - "we can use two pointer + set like maintain i,j and also insert jth character to set like while set size is equal to our window j-i+1 then maximize our answer and increase jth pointer till last index"See full answer

    Software Engineer
    Coding
    +4 more
  • Amazon logoAsked at Amazon 

    "class Node: def init(self, value): self.value = value self.children = [] def inorder_traversal(root): if not root: return [] result = [] n = len(root.children) for i in range(n): result.extend(inorder_traversal(root.children[i])) if i == n // 2: result.append(root.value) if n == 0: result.append(root.value) return result Example usage: root = Node(1) child1 = Node(2) chil"

    Teddy Y. - "class Node: def init(self, value): self.value = value self.children = [] def inorder_traversal(root): if not root: return [] result = [] n = len(root.children) for i in range(n): result.extend(inorder_traversal(root.children[i])) if i == n // 2: result.append(root.value) if n == 0: result.append(root.value) return result Example usage: root = Node(1) child1 = Node(2) chil"See full answer

    Software Engineer
    Coding
    +1 more
  • +2

    "Traverse the array of points while computing the distance and pushing it to the heap. Then traverse again the heap and pop the k closest. Time O(nlogn) Space O(n)"

    Dadja Z. - "Traverse the array of points while computing the distance and pushing it to the heap. Then traverse again the heap and pop the k closest. Time O(nlogn) Space O(n)"See full answer

    Software Engineer
    Coding
    +2 more
  • Coinbase logoAsked at Coinbase 
    Frontend Engineer
    Coding
  • "Started by asking clarification questions regarding design constraints and desired features. Break down the into re-usable components - HeroImg and Carousel (with 3 images rendered) Code the components and managed the state for both in the parent component."

    Akshay J. - "Started by asking clarification questions regarding design constraints and desired features. Break down the into re-usable components - HeroImg and Carousel (with 3 images rendered) Code the components and managed the state for both in the parent component."See full answer

    Frontend Engineer
    Coding
  • Meta (Facebook) logoAsked at Meta (Facebook) 
    Software Engineer
    Coding
    +1 more
  • Adobe logoAsked at Adobe 
    Video answer for 'Explain how to find a target sum in an array.'
    +3

    "A recursive backtracking solution in python. def changeSigns(nums: List[int], S: int) -> int: res = [] n = len(nums) def backtrack(index, curr, arr): if curr == S and len(arr) == n: res.append(arr[:]) return if index >= len(nums): return for i in range(index, n): add +ve number arr.append(nums[i]) backtrack(i+1, curr + nums[i], arr) arr.pop() "

    Yugaank K. - "A recursive backtracking solution in python. def changeSigns(nums: List[int], S: int) -> int: res = [] n = len(nums) def backtrack(index, curr, arr): if curr == S and len(arr) == n: res.append(arr[:]) return if index >= len(nums): return for i in range(index, n): add +ve number arr.append(nums[i]) backtrack(i+1, curr + nums[i], arr) arr.pop() "See full answer

    Software Engineer
    Coding
    +1 more
  • TikTok logoAsked at TikTok 

    "class Solution: def lengthOfLIS(self, nums: List[int]) -> int: temp = [nums[0]] for num in nums: if temp[-1]< num: temp.append(num) else: index = bisect_left(temp,num) temp[index] = num return len(temp) "

    Mahima M. - "class Solution: def lengthOfLIS(self, nums: List[int]) -> int: temp = [nums[0]] for num in nums: if temp[-1]< num: temp.append(num) else: index = bisect_left(temp,num) temp[index] = num return len(temp) "See full answer

    Machine Learning Engineer
    Coding
    +1 more
  • "I solved it using recursion and then memoization. Used Dynamic programming approach"

    Ravi teja N. - "I solved it using recursion and then memoization. Used Dynamic programming approach"See full answer

    Software Engineer
    Coding
    +1 more
  • Adobe logoAsked at Adobe 
    +20

    "Idea for solution: Reverse the complete char array Reverse the words separated by space. i.e. Find the space characters and the reverse the subarray between two space characters. vector reverseSubarray(vector& arr, int s, int e) { while (s reverseWords(vector& arr ) { int n = arr.size(); reverse(arr, 0, n - 1"

    Rahul M. - "Idea for solution: Reverse the complete char array Reverse the words separated by space. i.e. Find the space characters and the reverse the subarray between two space characters. vector reverseSubarray(vector& arr, int s, int e) { while (s reverseWords(vector& arr ) { int n = arr.size(); reverse(arr, 0, n - 1"See full answer

    Software Engineer
    Coding
    +4 more
  • +16

    "SELECT u.user_id, u.user_name, u.email, ROUND(AVG(CASE WHEN b.status = 'Unmatched' THEN 1.0 ELSE 0 END), 2) AS avgunmatchedbookings FROM users u LEFT JOIN bookings b ON u.userid = b.userid GROUP BY u.user_id, u.user_name, u.email; `"

    Akshay D. - "SELECT u.user_id, u.user_name, u.email, ROUND(AVG(CASE WHEN b.status = 'Unmatched' THEN 1.0 ELSE 0 END), 2) AS avgunmatchedbookings FROM users u LEFT JOIN bookings b ON u.userid = b.userid GROUP BY u.user_id, u.user_name, u.email; `"See full answer

    Coding
    SQL
  • Meta (Facebook) logoAsked at Meta (Facebook) 
    Video answer for 'Merge Intervals'
    +35

    "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
    Coding
    +6 more
  • +11

    "Required output in the solution not the one requested from the question. only customerid, firstname, last_name and years were required. Please this needs to be very clear. Otherwise my answer is with totalorderyear as ( SELECT o.customer_id, c.first_name, c.last_name, EXTRACT(YEAR FROM o.orderdate) AS orderyear, COUNT(o.orderid) AS totalorders FROM orders o LEFT JOIN customers c ON c.customerid = o.customerid GROUP BY o.customerid, c.firstname, c.last"

    Gloriose H. - "Required output in the solution not the one requested from the question. only customerid, firstname, last_name and years were required. Please this needs to be very clear. Otherwise my answer is with totalorderyear as ( SELECT o.customer_id, c.first_name, c.last_name, EXTRACT(YEAR FROM o.orderdate) AS orderyear, COUNT(o.orderid) AS totalorders FROM orders o LEFT JOIN customers c ON c.customerid = o.customerid GROUP BY o.customerid, c.firstname, c.last"See full answer

    Coding
    SQL
Showing 41-60 of 363