Skip to content

General Bug Summary

Xin Wan edited this page Jan 15, 2018 · 7 revisions
  • char doesn't have empty one, which means there is no expression like:
char c = '';
  • Binary Search question: definitely make sure the return value is the index or the value on the position. *[Binary Search] should assign mid idx to left, right, rather than assign left or right idx to mid;
// Right way:
if (array[mid] < target) {
    left = mid;
} else {
    right = mid;
}

// Wrong way:
if (array[mid] < target) {
    mid = left;
} else {
    mid = right;
}
  • When you want to get average. Please don't forget to change int to double first. Otherwise, you may lose the precision. (346. Moving Average from Data Stream https://leetcode.com/problems/moving-average-from-data-stream/description/)

  • For some stack question, you may need to check peek() to see if you will push element to stack or not. **Do not forget stack or queue empty time **

Need to research

Clone this wiki locally