Coding Interview Questions

Review this list of 344 coding interview questions and answers verified by hiring managers and candidates.
  • Airbnb logoAsked at Airbnb 
    Video answer for 'Find the minimum window substring.'

    "sliding window"

    Ashley M. - "sliding window"See full answer

    Software Engineer
    Coding
    +1 more
  • "We are asked to calculate Sum(over value) for time in (t - window_size, t) where key in (key criteria). To develop a function to set this up. Let w be the window size. I would have an observer of some kind note the key-value, and for the first w windows just add the value to a temporary variable in memory if the key meets the key criteria. Then it would delete the oldest value and add the new value if the new key meets the criteria. At each step after "w", we would take the sum / w and store"

    Prashanth A. - "We are asked to calculate Sum(over value) for time in (t - window_size, t) where key in (key criteria). To develop a function to set this up. Let w be the window size. I would have an observer of some kind note the key-value, and for the first w windows just add the value to a temporary variable in memory if the key meets the key criteria. Then it would delete the oldest value and add the new value if the new key meets the criteria. At each step after "w", we would take the sum / w and store"See full answer

    Software Engineer
    Coding
    +1 more
  • +1

    "WITH suspicious_transactions AS ( SELECT c.first_name, c.last_name, t.receipt_number, COUNT(t.receiptnumber) OVER (PARTITION BY c.customerid) AS noofoffences FROM customers c JOIN transactions t ON c.customerid = t.customerid WHERE t.receipt_number LIKE '%999%' OR t.receipt_number LIKE '%1234%' OR t.receipt_number LIKE '%XYZ%' ) SELECT first_name, last_name, receipt_number, noofoffences FROM suspicious_transactions WHERE noofoffences >= 2;"

    Jayveer S. - "WITH suspicious_transactions AS ( SELECT c.first_name, c.last_name, t.receipt_number, COUNT(t.receiptnumber) OVER (PARTITION BY c.customerid) AS noofoffences FROM customers c JOIN transactions t ON c.customerid = t.customerid WHERE t.receipt_number LIKE '%999%' OR t.receipt_number LIKE '%1234%' OR t.receipt_number LIKE '%XYZ%' ) SELECT first_name, last_name, receipt_number, noofoffences FROM suspicious_transactions WHERE noofoffences >= 2;"See full answer

    Data Scientist
    Coding
    +1 more
  • +1

    "SELECT d.departmentname,SUM(o.orderamount) AS total_revenue FROM orders o JOIN departments d ON d.departmentid =o.departmentid WHERE o.orderdate >= CURRENTDATE - INTERVAL '12 months' GROUP BY d.department_name ORDER BY total_revenue DESC; `"

    Derrick M. - "SELECT d.departmentname,SUM(o.orderamount) AS total_revenue FROM orders o JOIN departments d ON d.departmentid =o.departmentid WHERE o.orderdate >= CURRENTDATE - INTERVAL '12 months' GROUP BY d.department_name ORDER BY total_revenue DESC; `"See full answer

    Data Scientist
    Coding
    +1 more
  • 🧠 Want an expert answer to a question? Saving questions lets us know what content to make next.

  • Nvidia logoAsked at Nvidia 

    "virtual function is a member function declared with virtual keyword in a base class. It enables derived classes to redefine this function with their own specific implementations."

    Sonia M. - "virtual function is a member function declared with virtual keyword in a base class. It enables derived classes to redefine this function with their own specific implementations."See full answer

    Software Engineer
    Coding
    +1 more
  • Salesforce logoAsked at Salesforce 

    "Bitshift the number to the right and keep track of the 1's you encounter. If you bitshift it completely and only encounter one 1, it is a power of two."

    Nils G. - "Bitshift the number to the right and keep track of the 1's you encounter. If you bitshift it completely and only encounter one 1, it is a power of two."See full answer

    Software Engineer
    Coding
    +1 more
  • Apple logoAsked at Apple 
    Software Engineer
    Coding
    +2 more
  • Apple logoAsked at Apple 

    "class TrieNode { constructor() { this.children = {}; this.isEndOfWord = false; } } class Trie { constructor() { this.root = new TrieNode(); } insert(word) { let node = this.root; for (const char of word) { if (!node.children[char]) { node.children[char] = new TrieNode(); } node = node.children[char]; } node.isEndOfWord = true; } search(word) { l"

    Tiago R. - "class TrieNode { constructor() { this.children = {}; this.isEndOfWord = false; } } class Trie { constructor() { this.root = new TrieNode(); } insert(word) { let node = this.root; for (const char of word) { if (!node.children[char]) { node.children[char] = new TrieNode(); } node = node.children[char]; } node.isEndOfWord = true; } search(word) { l"See full answer

    Data Engineer
    Coding
    +3 more
  • +6

    "Good Question, but I would've marked this as medium not hard difficulty, since it's just a straightforward traversal."

    Ahmed A. - "Good Question, but I would've marked this as medium not hard difficulty, since it's just a straightforward traversal."See full answer

    Coding
    Data Structures & Algorithms
  • "SELECT upsellcampaignid, COUNT(DISTINCT trans.userid) AS eligibleusers FROM campaign JOIN "transaction" AS trans ON transactiondate BETWEEN datestart AND date_end JOIN user ON trans.userid = user.userid WHERE iseligibleforupsellcampaign = 1 GROUP BY upsellcampaignid `"

    Alina G. - "SELECT upsellcampaignid, COUNT(DISTINCT trans.userid) AS eligibleusers FROM campaign JOIN "transaction" AS trans ON transactiondate BETWEEN datestart AND date_end JOIN user ON trans.userid = user.userid WHERE iseligibleforupsellcampaign = 1 GROUP BY upsellcampaignid `"See full answer

    Data Scientist
    Coding
    +1 more
  • Nvidia logoAsked at Nvidia 

    "Function that is passed as an argument or parameter to another function and it gets executed when the function that it is passed to gets executed"

    Susmita S. - "Function that is passed as an argument or parameter to another function and it gets executed when the function that it is passed to gets executed"See full answer

    Software Engineer
    Coding
    +1 more
  • Meta (Facebook) logoAsked at Meta (Facebook) 
    Software Engineer
    Coding
    +1 more
  • Asked at Confluent 
    Software Engineer
    Coding
    +1 more
  • Meta (Facebook) logoAsked at Meta (Facebook) 
    Video answer for 'Find the common ancestors in a tree.'
    Machine Learning Engineer
    Coding
    +1 more
  • "Construct a min-heap either inplace, or by making a copy of the array and then applying heapify on that copy. This is done in O(n) time. Maintain two zero-initialised variables - sum and count. Keep popping off the heap while sum < k, and update count. In the worst case you will have to do n pops, and each pop is O(log n), so the algorithm would take O(n log n) in total. Space complexity depends on whether you're allowed to modify inplace or not, so either O(1) or O(n) respectively."

    Anonymous Wolf - "Construct a min-heap either inplace, or by making a copy of the array and then applying heapify on that copy. This is done in O(n) time. Maintain two zero-initialised variables - sum and count. Keep popping off the heap while sum < k, and update count. In the worst case you will have to do n pops, and each pop is O(log n), so the algorithm would take O(n log n) in total. Space complexity depends on whether you're allowed to modify inplace or not, so either O(1) or O(n) respectively."See full answer

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

    " O(n) time, O(1) space from typing import List def maxsubarraysum(nums: List[int]) -> int: if len(nums) == 0: return 0 maxsum = currsum = nums[0] for i in range(1, len(nums)): currsum = max(currsum + nums[i], nums[i]) maxsum = max(currsum, max_sum) return max_sum debug your code below print(maxsubarraysum([-1, 2, -3, 4])) `"

    Rick E. - " O(n) time, O(1) space from typing import List def maxsubarraysum(nums: List[int]) -> int: if len(nums) == 0: return 0 maxsum = currsum = nums[0] for i in range(1, len(nums)): currsum = max(currsum + nums[i], nums[i]) maxsum = max(currsum, max_sum) return max_sum debug your code below print(maxsubarraysum([-1, 2, -3, 4])) `"See full answer

    Software Engineer
    Coding
    +4 more
Showing 201-220 of 344