C
de
S
pace
Explore
Log In
Explore
Sign Up
Log In
drewkovalenko293
22.05.2026 11:10
2
Simple chatbot
Clean and minimal
helper.py
class Node: def __init__(self, val): self.val = val self.next = None class LinkedList: def __init__(self): self.head = None def append(self, val): if not self.head: self.head = Node(val) return cur = self.head while cur.next: cur = cur.next cur.next = Node(val) def display(self): cur = self.head while cur: print(cur.val, end=' ') cur = cur.next print() ll = LinkedList() ll.append(1); ll.append(2); ll.append(3) ll.display()
main.py
def binary_search(arr, target): lo, hi = 0, len(arr) - 1 while lo <= hi: mid = (lo + hi) // 2 if arr[mid] == target: return mid elif arr[mid] < target: lo = mid + 1 else: hi = mid - 1 return -1 print(binary_search([1,3,5,7,9], 7))
Idle
Try It
Clear
Log in
to leave a comment
Are you sure you want to delete this post?
Delete
Cancel