MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / binarySearch2

Method binarySearch2

Array/Search2DMatrixII.py:77–98  ·  view source on GitHub ↗
(self, rawList, target)

Source from the content-addressed store, hash-verified

75"""
76class Solution(object):
77 def binarySearch2(self, rawList, target):
78 split = len(rawList) // 2
79
80 left = rawList[:split]
81 right = rawList[split:]
82
83 if not left and not right:
84 return False
85
86 if left and left[-1] == target:
87 return True
88
89 if right and right[0] == target:
90 return True
91
92 if len(left) > 1 and left[-1] > target:
93 return self.binarySearch2(left, target)
94
95 if len(right) > 1 and right[0] < target:
96 return self.binarySearch2(right, target)
97
98 return False
99
100 def searchMatrix(self, matrix, target):
101

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected