title: Question about function design
body: <p>I just had an interview question about how I design a simple function - find the second largest number in an Int Array.</p>
  
  <pre><code>int findSecondLargest(int * arr, int len){
      int second = 0;
      ...
  
      return second;
  }
  </code></pre>
  
  <p>However, I was asked the following questions about how I deal with the issues.</p>
  
  <ol>
  <li>If the len is less than 2(I think we can return a special value, like 0, or MinInt.)</li>
  <li>But, if the second largest is 0. (Since in this case, I can not differentiate between an error and a normal return value. so  I might throw an exception)</li>
  <li>If the array is {1,1,1}(Since 1 is the largest number, not an second largest. so I might throw an exception)</li>
  </ol>
  
  <p>I really felt confused. I think it is not possible to deal with all situations. We usually have to document the usage of our function, instead of throw exception.</p>
  
  <p>Hope some advice. Thanks</p>
  
  <p>//The function body is written by myself. I really like the design supposed by Donotalo and PigBen</p>