Verified Jobs Live
C++ and C Intermediate Level ~1 min read

Arrays Interview Questions

Quick Revision Summary

You are given an array with integers between 1 and 1,000,000. One integer is in the array twice. How can you determine which one? Can you think of a way to do it using little ex...

Interactive Practice Mode
Formulate your thoughts or take notes before revealing the model solution.
Model Answer & Deep-Dive Explanation
  • You are given an array with integers between 1 and 1,000,000. One integer is in the array twice. How can you determine which one? Can you think of a way to do it using little extra memory.
  • You are given an array with integers between 1 and 1,000,000. One integer is missing. How can you determine which one? Can you think of a way to do it while iterating through the array only once. Is overflow a problem in the solution? Why not?
  • Retu s the largest sum of contiguous integers in the array
    Example: if the input is (-10, 2, 3, -2, 0, 5, -15), the largest sum is 8
    int GetLargestContiguousSum(int* anData, int len)
  • Implement Shuffle given an array containing a deck of cards and the number of cards. Now make it O(n).
  • Retu the sum two largest integers in an array
    int SumTwoLargest(int* anData, int size)
  • Sum n largest integers in an array of integers where every integer is between 0 and 9
    int SumNLargest(int* anData, int size, int n)

Interviewer Evaluation Points & Scoring Rubric

  • 1 Analyze Time Complexity (Big O) and Space Complexity explicitly.
  • 2 Address boundary cases: empty input, null pointers, single elements.
  • 3 Write idiomatic, readable code with descriptive variable naming.