from typing import List, Optional
def binary_search(arr: List[int], target: int) -> Optional[int]:
"""
Performs binary search on a sorted list to find the index of a target value.
Args:
arr (List[int]): A sorted list of integers to search through.
target (int): The integer value to search for.
Returns:
Optional[int]: The index of the target value if found, None otherwise.
Time Complexity: O(log n)
Space Complexity: O(1)
Examples:
>>> binary_search([1, 2, 3, 4, 5], 3)
2
>>> binary_search([1, 2, 3, 4, 5], 6)
None
"""
if not arr:
return None
left: int = 0
right: int = len(arr) - 1
while left <= right:
mid: int = left + (right - left) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
left = mid + 1
else:
right = mid - 1
return None