Simple pattern recognition in arrays is a great way to warm up for more complex problems. "Three Consecutive Odds" asks you to determine if an integer array contains three consecutive odd numbers. If it does, return true; otherwise, return false.
This three consecutive odds interview question is an "easy" level problem used by companies like Meta, Amazon, and Google. It tests your basic loop proficiency and your ability to check multiple adjacent elements without going out of bounds. It evaluates whether you can write clean, concise, and bug-free code for a simple requirement.
This problem follows the Array interview pattern.
n-2 element.i, check if arr[i], arr[i+1], and arr[i+2] are all odd (using the modulo operator: x % 2 != 0).i, return true immediately.Array: [2, 6, 4, 1, 3, 5, 7, 10]
In "Three Consecutive Odds coding problem," the most common mistake is an "index out of bounds" error. Candidates often try to check i+1 or i+2 without stopping the loop early enough. Another mistake is using a counter that doesn't reset properly when an even number is encountered, which would incorrectly return true for [1, 2, 3, 4, 5].
Practice "sliding window" or "adjacent element" checks until they are natural. Always be mindful of your loop boundaries. Even for simple problems, strive for the most readable code possible, as clarity is highly valued in technical interviews.