Skip to main content

Coding Interview Questions

Review this list of 418 Coding interview questions and answers verified by hiring managers and candidates.
  • Software Engineer
    Coding
  • Adobe logoAsked at Adobe 
    Video answer for 'Edit distance'
    +32

    "from collections import deque def updateword(words, startword, end_word): if end_word not in words: return None # Early exit if end_word is not in the dictionary queue = deque([(start_word, 0)]) # (word, steps) visited = set([start_word]) # Keep track of visited words while queue: word, steps = queue.popleft() if word == end_word: return steps # Found the target word, return steps for i in range(len(word)): "

    叶 路. - "from collections import deque def updateword(words, startword, end_word): if end_word not in words: return None # Early exit if end_word is not in the dictionary queue = deque([(start_word, 0)]) # (word, steps) visited = set([start_word]) # Keep track of visited words while queue: word, steps = queue.popleft() if word == end_word: return steps # Found the target word, return steps for i in range(len(word)): "See full answer

    Software Engineer
    Coding
    +3 more
  • xAI logoAsked at xAI 

    "=>user => window {addfile(void * file, userID, chatID) => add to fileList=> Display(file pointer)} => file=> pointer to DB, thumbnail => file will stores in database, pointer to the file+ thumbnail to be visible to chat => file is associated with chat => chat : users list, notepad: post { , user posted} class file{ void * buffer = nullptr; string fileName = nullptr; public: file( void content, string filename ):fileName ("

    Ankush G. - "=>user => window {addfile(void * file, userID, chatID) => add to fileList=> Display(file pointer)} => file=> pointer to DB, thumbnail => file will stores in database, pointer to the file+ thumbnail to be visible to chat => file is associated with chat => chat : users list, notepad: post { , user posted} class file{ void * buffer = nullptr; string fileName = nullptr; public: file( void content, string filename ):fileName ("See full answer

    Software Engineer
    Coding
    +1 more
  • Video answer for 'Employee Earnings.'
    +65

    "select e.firstname as firstname, m.salary as manager_salary from employees e join employees m on e.manager_id = m.id where e.salary > m.salary; `"

    Ravi K. - "select e.firstname as firstname, m.salary as manager_salary from employees e join employees m on e.manager_id = m.id where e.salary > m.salary; `"See full answer

    Software Engineer
    Coding
    +4 more
  • Bloomberg logoAsked at Bloomberg 

    " max Min 4, 3, 1 , 6, 7, 8 1 3 4 6 7 8 9 0 1 2 3 0 1 1 2 3 6 7 8 9 class MedianFinder{ std::priority_queue minHeap; std::priority_queue, greater> maxHeap; int numEleMaxheap = 0, numEleMinHeap = 0; public: void addNum( int n) { if(numEleMaxheap == numEleMinHeap ) { maxHeap.push(n); int maxofmaxheap = maxHeap.top(); maxHeap.pop(); "

    Ankush G. - " max Min 4, 3, 1 , 6, 7, 8 1 3 4 6 7 8 9 0 1 2 3 0 1 1 2 3 6 7 8 9 class MedianFinder{ std::priority_queue minHeap; std::priority_queue, greater> maxHeap; int numEleMaxheap = 0, numEleMinHeap = 0; public: void addNum( int n) { if(numEleMaxheap == numEleMinHeap ) { maxHeap.push(n); int maxofmaxheap = maxHeap.top(); maxHeap.pop(); "See full answer

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

  • Adobe logoAsked at Adobe 
    +36

    "Was this for an entry level engineer role?"

    Yeshwanth D. - "Was this for an entry level engineer role?"See full answer

    Software Engineer
    Coding
    +4 more
  • +8

    "Answer: select fromcaller, count(DISTINCT tocallee) as num_calls from calls group by fromcaller having count(DISTINCT tocallee) >= 3 Setup: CREATE TABLE calls ( from_caller VARCHAR(20), to_callee VARCHAR(20) ); INSERT INTO calls (fromcaller, tocallee) VALUES ('Alice', 'Bob'), ('Charlie', 'Dave'), ('Alice', 'Frank'), ('Charlie', 'Heidi'), ('Charlie', 'Judy'); "

    KAI - "Answer: select fromcaller, count(DISTINCT tocallee) as num_calls from calls group by fromcaller having count(DISTINCT tocallee) >= 3 Setup: CREATE TABLE calls ( from_caller VARCHAR(20), to_callee VARCHAR(20) ); INSERT INTO calls (fromcaller, tocallee) VALUES ('Alice', 'Bob'), ('Charlie', 'Dave'), ('Alice', 'Frank'), ('Charlie', 'Heidi'), ('Charlie', 'Judy'); "See full answer

    Data Scientist
    Coding
    +3 more
  • Uber logoAsked at Uber 

    "public int minInsertions(String s) { int n = s.length(); int dp = new intn; for (int len = 2; len <= n; n++) { for (int i = 0; i + len - 1 < n: i++) { int j = i + len - 1; if (s.charAt(i) == s.charAt(j)) { dpi = dpi + 1; } else { dpi = 1 + Math.min(dpi + 1, dpi); } } } return dp0; } `"

    Jatin S. - "public int minInsertions(String s) { int n = s.length(); int dp = new intn; for (int len = 2; len <= n; n++) { for (int i = 0; i + len - 1 < n: i++) { int j = i + len - 1; if (s.charAt(i) == s.charAt(j)) { dpi = dpi + 1; } else { dpi = 1 + Math.min(dpi + 1, dpi); } } } return dp0; } `"See full answer

    Software Engineer
    Coding
    +1 more
  • IBM logoAsked at IBM 
    +59

    "SELECT MIN(id) AS id, TRIM(LOWER(email)) AS cleaned_email FROM users GROUP BY cleaned_email ORDER BY id `"

    Salome L. - "SELECT MIN(id) AS id, TRIM(LOWER(email)) AS cleaned_email FROM users GROUP BY cleaned_email ORDER BY id `"See full answer

    Backend Engineer
    Coding
    +3 more
  • +2

    "Try not to take hints from the interviewer for solving the problem. They may provide hints but it would impact the final decision "

    Laxman kishore K. - "Try not to take hints from the interviewer for solving the problem. They may provide hints but it would impact the final decision "See full answer

    Software Engineer
    Coding
    +1 more
  • LinkedIn logoAsked at LinkedIn 

    "Requirements and Goals Primary Goal:Store key-value pairs in a cache with efficient access (reads/writes). Evict items based on a certain “rank,” which might reflect popularity, frequency, or custom ranking logic. Functional Requirements:Put(key, value, rank): Insert or update a key with the given value and rank. Get(key): Retrieve the value associated with the key if it exists. Evict(): If the cache is at capacity, evict the item with the lowest rank (or according"

    Alvis F. - "Requirements and Goals Primary Goal:Store key-value pairs in a cache with efficient access (reads/writes). Evict items based on a certain “rank,” which might reflect popularity, frequency, or custom ranking logic. Functional Requirements:Put(key, value, rank): Insert or update a key with the given value and rank. Get(key): Retrieve the value associated with the key if it exists. Evict(): If the cache is at capacity, evict the item with the lowest rank (or according"See full answer

    Engineering Manager
    Coding
    +1 more
  • Adobe logoAsked at Adobe 
    +37

    "def is_palindrome(s: str) -> bool: new = '' for a in s: if a.isalpha() or a.isdigit(): new += a.lower() return (new == new[::-1]) debug your code below print(is_palindrome('abcba')) `"

    Anonymous Roadrunner - "def is_palindrome(s: str) -> bool: new = '' for a in s: if a.isalpha() or a.isdigit(): new += a.lower() return (new == new[::-1]) debug your code below print(is_palindrome('abcba')) `"See full answer

    Software Engineer
    Coding
    +4 more
  • Apple logoAsked at Apple 

    "This is a geometric variation of the "Sliding Window" technique. The core challenge is converting a 2D coordinate problem into a 1D linear problem using angles. The standard approach is the Angular Sweep. By converting the Cartesian coordinates (x,y) of every tree into Polar coordinates (specifically the angle θ), we can process the trees based on the direction they lie in relative to the observer. The Strategy Coordinate Translation: Calculate the relative coordinates (Δx,Δy) for"

    Ashish D. - "This is a geometric variation of the "Sliding Window" technique. The core challenge is converting a 2D coordinate problem into a 1D linear problem using angles. The standard approach is the Angular Sweep. By converting the Cartesian coordinates (x,y) of every tree into Polar coordinates (specifically the angle θ), we can process the trees based on the direction they lie in relative to the observer. The Strategy Coordinate Translation: Calculate the relative coordinates (Δx,Δy) for"See full answer

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

    "Since the problem asks for a O(logN) solution, I have to assume that the numbers are already sorted, meaning the same number are adjacent to each other, the value of the numbers shouldn't matter, and they expect us to use Binary Search. First, we should analyze the pattern of a regular number array without a single disrupter. Index: 0 1 2 3 4. 5 6. 7. 8. 9 Array:[1, 1, 2, 2, 4, 4, 5, 5, 6, 6] notice the odd indexes are always referencing the second of the reoccurring numbers and t"

    Bamboo Y. - "Since the problem asks for a O(logN) solution, I have to assume that the numbers are already sorted, meaning the same number are adjacent to each other, the value of the numbers shouldn't matter, and they expect us to use Binary Search. First, we should analyze the pattern of a regular number array without a single disrupter. Index: 0 1 2 3 4. 5 6. 7. 8. 9 Array:[1, 1, 2, 2, 4, 4, 5, 5, 6, 6] notice the odd indexes are always referencing the second of the reoccurring numbers and t"See full answer

    Software Engineer
    Coding
  • "int getMaxWater(vector& nums) { int n = nums.size(); int mx = INT_MIN; int i=0, j=n-1; while(i<j) { int water = (j - i) * min(nums[i], nums[j]); mx = max(mx, water); if(nums[i] < nums[j]){ i++; } else { j--; } } return mx; } `"

    Richard W. - "int getMaxWater(vector& nums) { int n = nums.size(); int mx = INT_MIN; int i=0, j=n-1; while(i<j) { int water = (j - i) * min(nums[i], nums[j]); mx = max(mx, water); if(nums[i] < nums[j]){ i++; } else { j--; } } return mx; } `"See full answer

    Data Engineer
    Coding
    +3 more
  • Amazon logoAsked at Amazon 

    "function longestCommonPrefix(arr1, arr2) { const prefixSet = new Set(); for (let num of arr1) { let str = num.toString(); for (let i = 1; i <= str.length; i++) { prefixSet.add(str.substring(0, i)); } } let longestPrefix = ""; for (let num of arr2) { let str = num.toString(); for (let i = 1; i <= str.length; i++) { let prefix = str.substring(0, i); if (prefixSet.has(prefix)) { "

    Maykon henrique D. - "function longestCommonPrefix(arr1, arr2) { const prefixSet = new Set(); for (let num of arr1) { let str = num.toString(); for (let i = 1; i <= str.length; i++) { prefixSet.add(str.substring(0, i)); } } let longestPrefix = ""; for (let num of arr2) { let str = num.toString(); for (let i = 1; i <= str.length; i++) { let prefix = str.substring(0, i); if (prefixSet.has(prefix)) { "See full answer

    Software Engineer
    Coding
    +1 more
  • Video answer for 'How would you remove duplicates in a string?'
    +11

    " O(n) - characters in the string O(n) - stack def identify_adjacent(s: str, k: int) -> str: stack = [] n = len(s) for ch in s: if stack: topch, topcnt = stack[-1] if top_ch == ch: top_cnt += 1 stack[-1] = (ch, top_cnt) else: top_cnt = 1 stack.append((ch,1)) if top_cnt == k: stack.pop() else: stack.append"

    Rick E. - " O(n) - characters in the string O(n) - stack def identify_adjacent(s: str, k: int) -> str: stack = [] n = len(s) for ch in s: if stack: topch, topcnt = stack[-1] if top_ch == ch: top_cnt += 1 stack[-1] = (ch, top_cnt) else: top_cnt = 1 stack.append((ch,1)) if top_cnt == k: stack.pop() else: stack.append"See full answer

    Coding
    Data Structures & Algorithms
  • Oracle logoAsked at Oracle 

    "Since a bitonic array first increases then decreases, we can: Find the peak using binary search (O(log n)) Reverse the decreasing half Merge the two sorted halvesThis gives an overall time complexity of O(n)."

    Krishnaveni G. - "Since a bitonic array first increases then decreases, we can: Find the peak using binary search (O(log n)) Reverse the decreasing half Merge the two sorted halvesThis gives an overall time complexity of O(n)."See full answer

    Engineering Manager
    Coding
    +1 more
  • Anthropic logoAsked at Anthropic 
    Software Engineer
    Coding
Showing 1-20 of 418