Skip to content

General Bug Summary

Xin Wan edited this page Jan 14, 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;
}

Clone this wiki locally