Find the median of two sorted arrays
Given two sorted arrays nums1 and nums2, return the median of the two sorted arrays. The overall run time complexity should be O(log(m+n)).
Real questions from real interviews. Browse, filter, and prepare with crowdsourced experiences from engineers at top tech companies.
Given two sorted arrays nums1 and nums2, return the median of the two sorted arrays. The overall run time complexity should be O(log(m+n)).
Given the head of a singly linked list, reverse the list and return the reversed list. Implement both iterative and recursive solutions.
Explain what closures are in JavaScript. Provide an example of when you would use a closure and explain how it works.
Design and implement a data structure for Least Recently Used (LRU) cache. It should support get and put operations in O(1) time.
Write a debounce function that delays invoking a function until after a specified wait time has elapsed since the last time it was invoked.
Compare cookies, localStorage, and sessionStorage. What are the use cases, limitations, and security considerations for each?
Implement Promise.all in JavaScript without using the built-in method. Handle success and failure cases correctly.
Write a throttle function that limits the rate at which a function can be called. It should invoke the function at most once per specified time period.
Explain the difference between Promise.all() and Promise.allSettled() in JavaScript. When would you use each?
What is the Global Interpreter Lock in Python? How does it affect multi-threaded programs and what are the workarounds?
Explain the concept of memoization. Implement a memoize function and discuss when memoization is beneficial vs harmful.
Implement a trie data structure with insert, search, and autocomplete functionality. Optimize for prefix searches.
Compare REST and GraphQL APIs. What are the pros and cons of each approach? When would you choose one over the other?
Write a function that creates a deep copy of a JavaScript object. Handle nested objects, arrays, and edge cases like circular references.
Explain the rules of hooks in React. Why can't we call hooks inside loops, conditions, or nested functions?