Welcome To CodeCatch
Store, compile, and edit code snippets with other developers on CodeCatch
197
Users
504
Snippets
86
Languages
Unlimited
Uploads
Store
CodeCatch allows you to easily upload and keep track of code snippets that are important to you. Create a post, upload the post, and never waste your time finding code snippets again.
Compile
CodeCatch supports code compiling for 15+ languages such as JavaScript, Python, C, Go, and more. Simply click the "Run" button when viewing a post to see the compiled output.
# Python binary search function
def binary_search(arr, target):
left = 0
right = len(arr) - 1
while left <= right:
mid = (left + right) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
left = mid + 1
else:
right = mid - 1
return -1
# Usage
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
target = 7
result = binary_search(arr, target)
if result != -1:
print(f"Element is present at index {result}")
else:
print("Element is not present in array")
12345678910111213141516171819
Edit
Want to extend or simplify a code snippet? Click the Edit option while viewing a post to easily modify a block of code to your liking.
Lets See Some Posts!
Below are examples of featured posts to get you started. Click on a post to view and share it or to get the full CodeCatch experience.