## Qualcomm Interview Question for Product Security Engineers

• 0

Comment hidden because of low score. Click to expand.
1
of 1 vote

``````if ( ((a >= b) && a < b+sizeof(b)) ||
((b >= a) && b < a+sizeof(a)) )``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

Can you please clarify the problem and post the one line solution? Thanks a lot.

Comment hidden because of low score. Click to expand.
0
of 0 vote

Assumptions:
Let Source pointer be 's1' and destination pointer be 's2' and let the source string is of length 'n'
Solution:
Overlap condition:
if((s2>s1) && s2 < (s1+n))

Comment hidden because of low score. Click to expand.
0
of 0 vote

if(!((s1 > (s2 + n)) || (s2 > (s1 + n))) )

Comment hidden because of low score. Click to expand.
0
of 0 vote

so, here if i am not wrong we are trying both the cases right?

case 1: if the address of source pointer is less than the address of destination pointer(i.e the memory block where s1 is pointing is placed before the memory block where s2 is pointing)
for that we need to check, s2>s1+n, if not overlap occurs

case 2: if the address of destination pointer is less than the address of source pointer(i.e the memory block where s2 is pointing is placed before the memory block where s1 is pointing)
for that we need to check, s1>s2+n, if not overlap occurs

I guess that's wat anonymous checked....pls correct me if iam wrong!

Comment hidden because of low score. Click to expand.
0
of 0 vote

hey S3, are the assumptions correct? I guess not cos if you tried a long code then it probably means that the solution was not as straightforward as we are thinking.

Comment hidden because of low score. Click to expand.
0
of 0 vote

{s1,e1} and (s2,e2} be the two string.
((e1 - s1) && (e2 - s1)) >= 0
should solve the problem.

Comment hidden because of low score. Click to expand.
0
of 0 vote

if( (a+sizeof(a)) > b) && ( (b+sizeof(b)) > a))

where a, and b are pointers of two buffers

Comment hidden because of low score. Click to expand.
0
of 0 vote

hey s3, did you get selected for onsite interview? I am interviewing for this position as well and have finished 1 phone round. How many rounds did you have in total. Would be very helpful if you can answer.

Comment hidden because of low score. Click to expand.
0
of 0 vote

if( (a+sizeof(a)) > b) && ( (b+sizeof(b)) > a))

where a, and b are pointers of two buffers

....
I think it should be || rather than && .

Comment hidden because of low score. Click to expand.
0
of 0 vote

it should be &&

Comment hidden because of low score. Click to expand.
0
of 0 vote

if( (a+sizeof(a)) > b) || ( (b+sizeof(b)) > a)){
//if either of above condition true overlap occured;

}

where a, and b are pointers of two buffers

Comment hidden because of low score. Click to expand.
0
of 0 vote

suppose we have two pointer a and b
return(a>b?b+sizeof(b)>a?1:0:a+sizeof(a)>b?1:0)

Comment hidden because of low score. Click to expand.
0
of 0 vote

if S1 and S2 and are the start pointers and E1 and E2 are end pointers ..

(S1 - E2) * (S2 - E1) < 0

p.s ( En = Sn + sizeof(Sn) )

Comment hidden because of low score. Click to expand.
0
of 0 vote

Suppose s1, len1, s2, len2
if(! (s2 > s1 + len1 || s1 > s2 + len2))
{
//overlap
}

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.