Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
1,153 views
in Online Assessments by Expert (44,360 points) | 1,153 views

2 Answers

0 like 0 dislike
Best answer

image

Images of ques

 

by Expert (44,360 points)
0 like 0 dislike
Q1: Let's first think for some interval of integers that we'll denote [x^2, (x+1)^2), how many valid pairs can we make? All numbers in this range would have the same hash.
There are ((x+1)^2 - x^2) = (2x+1) integers in this range. Thus, we have (2x+1)^2 total pairs in the range.

 

Now, we can count the pairs in ranges up to the largest x < floor(sqrt(k)), and the remaining pairs in the range (floor(sqrt(k))^2, k) can be counted in a similar fashion.
by Expert (44,360 points)