7/08/2023

binary search problem

 Generic Binary Search Snippet

left = 0
right = len(nums)-1
while left <= right:
    #update mid
    mid = left+(right-left)//2
    if "find the element"
        do something # return mid index
    elif "cut the left half"
        left = mid+1
    else "cut the right half"
        right = mid-1
return "no found" # if not found, return left index

7/02/2023

Having vs Where Clause in SQL

  It is not a predefined rule but  in a good number of the SQL queries, we use WHERE prior to GROUP BY and HAVING after GROUP BY. The Where clause acts as a pre filter where as Having as a post filter.


https://www.geeksforgeeks.org/having-vs-where-clause-in-sql/