Write , choose , and let count the points of in the length- window ending at , for . Each element occurs in precisely such windows, so . The Cauchy-Schwarz inequality consequently gives
On the other hand, a pair of difference belongs to exactly windows; larger differences contribute none. The Sidon set condition permits at most one pair for each positive difference . Therefore
Combining these two estimates proves the sliding-window upper bound for Sidon sets:
If , the final inequality for this quadratic polynomial implies ; otherwise . With the chosen , and . Thus
Together with part (i)'s construction, this proves that the maximum cardinality is . The lower and upper error terms need not have the same size to establish that asymptotic conclusion.