# Beginner Problem Solving Patterns Part 2

Last time I wrote about the “ frequency counter” problem-solving pattern, I will introduce the “divide and conquer” problem-solving pattern this time. This problem-solving pattern is more advanced. I am here only to talk about the general idea of divide and conquer problem-solving pattern.

# Divide and Conquer

One most straightforward way to solve the problem is with one single for loop and find if the target exists, then return its index; otherwise, return -1 (linear search). However, the time complexity will be O(n), which is not as efficient as utilizing divide and conquer a binary search method. Binary search gives time Complexity (O log N), which is so much faster than O(n). The example data above is little. Assume the data set in an array has millions. With linear time, it will take forever. The binary search method would be more optimal and efficient compared to a linear search. This problem is a classic example of a divide and conquers problem-solving patterns. In fact, The binary search method is utilizing divide and conquer the problem-solving technique to search for a solution.