Median of two sorted arrays (optimal runtime)
I believe the test cases are not generated randomly. Your code will fail on almost all cases if the cases are generated in a random way.
For instance,
if array A is [0, 10000], and array B contains an arbitrary number of elements with arbitrary values from (0, 10000) except 5000, your code will fail. It is not relevant if the test cases contain negative numbers or not.