Skip to main content

Coding Interview Questions

Review this list of 419 Coding interview questions and answers verified by hiring managers and candidates.
  • Microsoft logoAsked at Microsoft 
    Add answer
    Security Engineer
    Coding
    +1 more
  • Salesforce logoAsked at Salesforce 
    1 answer

    "sanity testing, black box testing , white box testing, smoke testing,performance testing"

    Shubhangi S. - "sanity testing, black box testing , white box testing, smoke testing,performance testing"See full answer

    Software Engineer
    Coding
    +1 more
  • Meta logoAsked at Meta 
    Add answer
    Machine Learning Engineer
    Coding
    +1 more
  • Apple logoAsked at Apple 
    Add answer
    Software Engineer
    Coding
    +1 more
  • "I first asked few clarifying questions like the return array may need not contain the list of building in the same order, to which the interviewer agreed. Then I came up with an approach where we iterate the array from right to left and keep a max variable which will keep the value of the current max. When we find an item which is greater than max we update the max and add this element into our solution. The interviewer agreed for the approach. I discussed few corner scenarios with the interview"

    Rishabh N. - "I first asked few clarifying questions like the return array may need not contain the list of building in the same order, to which the interviewer agreed. Then I came up with an approach where we iterate the array from right to left and keep a max variable which will keep the value of the current max. When we find an item which is greater than max we update the max and add this element into our solution. The interviewer agreed for the approach. I discussed few corner scenarios with the interview"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.

  • "I try to solve this initially using quick select where will take a pivot element and position the remaining elements and check if the current index is answer or not and continue the same but it requires o(n*n), but interviewee is expecting the best from me, so at the end i tried solving using heaps where will check the difference between k and n-k to use min or max heap after that we will heap the array, and will keep popping the element k-1 and return the peek one which leads to answer."

    Mourya C. - "I try to solve this initially using quick select where will take a pivot element and position the remaining elements and check if the current index is answer or not and continue the same but it requires o(n*n), but interviewee is expecting the best from me, so at the end i tried solving using heaps where will check the difference between k and n-k to use min or max heap after that we will heap the array, and will keep popping the element k-1 and return the peek one which leads to answer."See full answer

    Software Engineer
    Coding
    +2 more
  • Adobe logoAsked at Adobe 
    2 answers

    "#include #include #include using namespace std; void printComs(int prev, int start, int end, int target) { if (start >= end) return; while (start target) { end--; } else { st"

    Iris F. - "#include #include #include using namespace std; void printComs(int prev, int start, int end, int target) { if (start >= end) return; while (start target) { end--; } else { st"See full answer

    Software Engineer
    Coding
    +4 more
  • Meta logoAsked at Meta 
    Add answer
    Machine Learning Engineer
    Coding
    +1 more
  • Apple logoAsked at Apple 
    1 answer

    "A doubly linked list is like a train where the engine is its head, and the compartments doors are interconnected, you can travel though them. The last compartment is the tail and is not connected with anything. Following is a visual: Head C1 C2 C3....Cn Tail Pseudocode: **class Node: Data pointer next pointer prev End class DLL = NULL //pointer to list insertion: if DLL is NULL: head = new Node() DLL = head DLL.prev = NU"

    Rasika D. - "A doubly linked list is like a train where the engine is its head, and the compartments doors are interconnected, you can travel though them. The last compartment is the tail and is not connected with anything. Following is a visual: Head C1 C2 C3....Cn Tail Pseudocode: **class Node: Data pointer next pointer prev End class DLL = NULL //pointer to list insertion: if DLL is NULL: head = new Node() DLL = head DLL.prev = NU"See full answer

    Software Engineer
    Coding
    +2 more
  • Apple logoAsked at Apple 
    Add answer
    Software Engineer
    Coding
    +1 more
  • Oracle logoAsked at Oracle 
    2 answers

    "def countuniqueoutfits(totalpants: int, uniquepants: int, totalshirts: int, uniqueshirts: int, totalhats: int, uniquehats: int) -> int: """ Number of unique outfits can simply be defined by (uniquepantschoose1uniqueshirtschoose1uniquehatschoose_1) (uniquepantschoose1*uniqueshirtschoose1) # Not wearing a hat nchoosek is n """ res = (uniquepants*uniqueshirtsuniquehats) + (uniquepantsunique_shirts) return res print(countuniqueoutfits(2, 1, 1, 1, 3, 2))"

    Sai R. - "def countuniqueoutfits(totalpants: int, uniquepants: int, totalshirts: int, uniqueshirts: int, totalhats: int, uniquehats: int) -> int: """ Number of unique outfits can simply be defined by (uniquepantschoose1uniqueshirtschoose1uniquehatschoose_1) (uniquepantschoose1*uniqueshirtschoose1) # Not wearing a hat nchoosek is n """ res = (uniquepants*uniqueshirtsuniquehats) + (uniquepantsunique_shirts) return res print(countuniqueoutfits(2, 1, 1, 1, 3, 2))"See full answer

    Data Scientist
    Coding
  • LinkedIn logoAsked at LinkedIn 
    1 answer

    " First, sort the array in ascending order. This ensures that we can easily check the triangle inequality condition. Use a loop to iterate through the array. For each triplet of consecutive elements, check if they satisfy the triangle inequality condition a+b>ca+b>c. As soon as you find a valid tuple, return it. If no valid tuple is found, return null. This approach is efficient with a time complexity of O(nlog⁡n)O(nlogn) due to the sorting step, followed by a linear scan of the array"

    Shivam P. - " First, sort the array in ascending order. This ensures that we can easily check the triangle inequality condition. Use a loop to iterate through the array. For each triplet of consecutive elements, check if they satisfy the triangle inequality condition a+b>ca+b>c. As soon as you find a valid tuple, return it. If no valid tuple is found, return null. This approach is efficient with a time complexity of O(nlog⁡n)O(nlogn) due to the sorting step, followed by a linear scan of the array"See full answer

    Machine Learning Engineer
    Coding
    +1 more
  • Nvidia logoAsked at Nvidia 
    Add answer
    Software Engineer
    Coding
    +1 more
  • Google logoAsked at Google 
    Add answer
    Machine Learning Engineer
    Coding
    +1 more
  • LinkedIn logoAsked at LinkedIn 
    3 answers

    "Count how many 1 and 2. calculate how many remaining items with '0'. Override existing data with knowledge of how many '0','1','2' in that order; TC=O(n), SC=O(1)"

    Konstantin P. - "Count how many 1 and 2. calculate how many remaining items with '0'. Override existing data with knowledge of how many '0','1','2' in that order; TC=O(n), SC=O(1)"See full answer

    Coding
    Data Structures & Algorithms
    +1 more
  • Apple logoAsked at Apple 
    Add answer
    Software Engineer
    Coding
    +1 more
  • 1 answer
    Software Engineer
    Coding
    +1 more
  • Apple logoAsked at Apple 
    1 answer

    "Function that transforms each elements in a collection and returns new collection with transformed elements"

    Susmita S. - "Function that transforms each elements in a collection and returns new collection with transformed elements"See full answer

    Software Engineer
    Coding
    +1 more
  • LinkedIn logoAsked at LinkedIn 
    Add answer
    Software Engineer
    Coding
    +2 more
  • WhatsApp logoAsked at WhatsApp 
    3 answers

    "Run length encoding. This will preserve order of values in vector."

    Yash S. - "Run length encoding. This will preserve order of values in vector."See full answer

    Coding
    Data Structures & Algorithms
    +1 more
Showing 361-380 of 419