U.S. CitiesCity-Data Forum Index
Go Back   City-Data Forum > General Forums > Work and Employment > Job Search
 [Register]
Please register to participate in our discussions with 2 million other members - it's free and quick! Some forums can only be seen by registered members. After you create your account, you'll be able to customize options and access all our 15,000 new posts/day with fewer ads.
View detailed profile (Advanced) or search
site with Google Custom Search

Search Forums  (Advanced)
Reply Start New Thread
 
Old 07-14-2013, 02:41 PM
 
218 posts, read 248,352 times
Reputation: 168

Advertisements

Quote:
Originally Posted by PhotoProIP View Post
Median of two sorted arrays - GeeksforGeeks | GeeksforGeeks

Is this what they asked?

What job was that for? sorry I didn't read all the 10+ pages!

I am ONLY asking because I am curious if the question was actually related to the job, or was one of those "out of the blue" trap questions.
The position title was Software Engineer, so yes, it was the type of question that is common for software engineering interviews these days, although I was unaware of that fact until recently. I had been practicing for the interview by actually writing code and making sure I remembered the nuances of C++/C and Java.

The question, if I'm to explain it in layman's terms, is like the following.

Say we have two collections of numbers in order. They are

(1, 1, 2, 5, 6, 9, 69) and (4, 6, 8, 8).

We want to find the median, or middle number, of the collection that is both those collections combined. Well, both those combined and sorted is

(1, 1, 2, 4, 5, 6, 6, 8, 8, 9, 69)

and so the middle number is 6.

But we actually want a procedure that can go this if we feed it any two sets. I'll demonstrate how the procedure works on those two sets. Call them A and B:

A = (1, 1, 2, 5, 6, 9, 69),
B = (4, 6, 8, 8).

Since median(A) = 5 < median(B) = 7, chop up A and B into

A = (6, 9, 69),
B = (4, 6).

Since median(A) = 9 > median(B) = 5, again chop A and B:

A = (6),
B = (6).

Bingo! The median is 6.

I would never have figured this out by myself.
Reply With Quote Quick reply to this message

 
Old 07-14-2013, 03:15 PM
FBJ
 
Location: Tall Building down by the river
39,615 posts, read 50,329,545 times
Reputation: 9451
Quote:
Originally Posted by Wry_Martini View Post
I could actually see a few very specific instances where you might accept the job, especially in niche industries. There are times when accepting such a job and staying with the company for 2 years, just for the sake of building your resume is a risk that pays off long-term.

Sometimes it's about working for a prestigious company, or in a position that's going to give you some amazing experience. Sometimes, having a 2 year stint doing that particular job will help you get your resume noticed in the future.

Or you might choose to gamble and take a job with a startup, where the pay stinks and the hours are long, in hopes that the risk pays off. (I know a few people who've done this. For 2, the risk paid off and paid off big time.)

This is certainly not the norm, though.

Anyone who would accept a job after hearing long days and low pay probably doesn't have a lot of confidence in their abilities.

Low pay + long hours = High stress
Reply With Quote Quick reply to this message
 
Old 07-14-2013, 03:48 PM
 
Location: PHL
287 posts, read 548,415 times
Reputation: 238
Quote:
Originally Posted by WestPhillyDude75 View Post
Anyone who would accept a job after hearing long days and low pay probably doesn't have a lot of confidence in their abilities.

Low pay + long hours = High stress
Or they are just looking for employment and do not care.
Reply With Quote Quick reply to this message
 
Old 07-14-2013, 03:56 PM
FBJ
 
Location: Tall Building down by the river
39,615 posts, read 50,329,545 times
Reputation: 9451
Quote:
Originally Posted by Merchant_ZZZ View Post
Or they are just looking for employment and do not care.

And then accept that long hour/low paying job and then start to be depressed because they are stuck in a job from hell with low pay.
Reply With Quote Quick reply to this message
 
Old 07-14-2013, 04:40 PM
 
Location: Washington State
18,561 posts, read 9,599,486 times
Reputation: 15808
Quote:
Originally Posted by Merchant_ZZZ View Post
She probably already had a job already.
We had just moved to this small town ...but she's a Computer Engineer so she had no trouble finding a job.
Reply With Quote Quick reply to this message
 
Old 07-14-2013, 08:22 PM
 
Location: San Francisco
2,279 posts, read 3,929,305 times
Reputation: 4008
Quote:
Originally Posted by WestPhillyDude75 View Post
Anyone who would accept a job after hearing long days and low pay probably doesn't have a lot of confidence in their abilities.

Low pay + long hours = High stress
Not necessarily.

Like I said, there are some jobs than can open a lot of future doors, so you suffer thru the long hours & low pay.

Check out the 2013 salary info for White House staffers, for example: White House Salaries | The White House
Reply With Quote Quick reply to this message
 
Old 07-15-2013, 01:47 PM
 
570 posts, read 1,505,891 times
Reputation: 353
Quote:
Originally Posted by GlitteringPrizes View Post
The position title was Software Engineer, so yes, it was the type of question that is common for software engineering interviews these days, although I was unaware of that fact until recently. I had been practicing for the interview by actually writing code and making sure I remembered the nuances of C++/C and Java.

The question, if I'm to explain it in layman's terms, is like the following.

Say we have two collections of numbers in order. They are

(1, 1, 2, 5, 6, 9, 69) and (4, 6, 8, 8).

We want to find the median, or middle number, of the collection that is both those collections combined. Well, both those combined and sorted is

(1, 1, 2, 4, 5, 6, 6, 8, 8, 9, 69)

and so the middle number is 6.

But we actually want a procedure that can go this if we feed it any two sets. I'll demonstrate how the procedure works on those two sets. Call them A and B:

A = (1, 1, 2, 5, 6, 9, 69),
B = (4, 6, 8, 8).

Since median(A) = 5 < median(B) = 7, chop up A and B into

A = (6, 9, 69),
B = (4, 6).

Since median(A) = 9 > median(B) = 5, again chop A and B:

A = (6),
B = (6).

Bingo! The median is 6.

I would never have figured this out by myself.

median always equal to the middle number or total of the two middle numbers /2.

the key is var medianLocation = (array1Count + array2Count) /2; The reset of the code doesn't matter because you can write it in many different way.

I do this in C#. It works for me.


public double getMedian(int[] arr1, int[] arr2)
{
var i = 0;
var j = 0;
var array1Count = arr1.Length;
var array2Count = arr2.Length;
var medianOld = 0;
var medianNew = 0;
var medianLocation = (array1Count + array2Count) /2;
for (var count = 0; count <= medianLocation; count++)
{

if (arr1[i] > arr2[j])
{
medianOld = medianNew;
medianNew = arr2[j];
if (array2Count - 1 > j)
{
j++;
}

}

else
{
medianOld = medianNew;
medianNew = arr1[i];
if (array1Count - 1 > i)
{
i++;
}
}
}
if ((array1Count + array2Count) % 2 == 0)
return (medianOld + medianNew) / 2.0;
else
return medianNew;
}

























Reply With Quote Quick reply to this message
 
Old 07-16-2013, 12:03 PM
 
2,038 posts, read 2,431,411 times
Reputation: 2099
Quote:
Originally Posted by WestPhillyDude75 View Post
And then accept that long hour/low paying job and then start to be depressed because they are stuck in a job from hell with low pay.
It might pay the bills while you look for something more suitable. You gotta do what you gotta do sometimes, even if it isn't the perfect job.
Reply With Quote Quick reply to this message
 
Old 07-16-2013, 12:15 PM
 
Location: Warner Robins, GA
917 posts, read 2,284,197 times
Reputation: 446
I don't understand why they give test questions like this during programming interviews anyway. I feel it doesn't represent the actual environment that people program in. I think giving someone a computer and asking them to solve the problems on their own with access to the internet would be a more realistic test.

I got my first programming job right out of high school and have been doing it for 8 years now. I had one interview that was extremely technical and honestly I just wasn't prepared for it. I learned from the experience though and will be more prepared for the future. Most of the interviews I have had were not like that. They ask general questions, some ask you to provide code samples, etc..
Reply With Quote Quick reply to this message
 
Old 07-16-2013, 12:20 PM
 
Location: SF Bay Area
13,343 posts, read 17,418,107 times
Reputation: 19654
Quote:
Originally Posted by tercel95 View Post
I don't understand why they give test questions like this during programming interviews anyway. I feel it doesn't represent the actual environment that people program in. I think giving someone a computer and asking them to solve the problems on their own with access to the internet would be a more realistic test.
They're testing your logic and approach on problem solving, not your Googling skills.
Reply With Quote Quick reply to this message
Please register to post and access all features of our very popular forum. It is free and quick. Over $68,000 in prizes has already been given out to active posters on our forum. Additional giveaways are planned.

Detailed information about all U.S. cities, counties, and zip codes on our site: City-data.com.


Reply
Please update this thread with any new information or opinions. This open thread is still read by thousands of people, so we encourage all additional points of view.

Quick Reply
Message:

Over $104,000 in prizes was already given out to active posters on our forum and additional giveaways are planned!

Go Back   City-Data Forum > General Forums > Work and Employment > Job Search
Follow City-Data.com founder on our Forum or

All times are GMT -6.

2005-2019, Advameg, Inc. · Please obey Forum Rules · Terms of Use and Privacy Policy · Bug Bounty

City-Data.com - Archive 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 - Top