Globaltech Research Interview Question for Software Engineer / Developers






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

Given a date, Count #days to 1/1/2000, mod (that is, %) it by 7, lookup the corresponding week-day (implement simple num2day() fn) and print. The key is that the lookup should assume 'Monday' in first position.

This is highly simplified by assuming 30-day months.

Say if date is 4/11/2009, we'll count days like this:
> (4-1)*30 + 11 + (2009-2000)*12*30 = 90 + 11 + 9*12*30 = 3341.
> 3341 % 7 = 2 ===> Tuesday.

Is it difficult to code?

- Nix October 17, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

were the assumptions given in the problem or you have added them?

- Anonymous November 01, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

i think in the above code it will be ...+(11-1)+...

- ab November 07, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Take the input of Month, Year, Day as ints

int MDS= (Year-1)*365  + parseInt((Year-1)/4) + (Month-1)*30 + (Day - 11)
int COR = parseInt((Year-1)/100) - 16
int (COR>0) {MDS = MDS-COR}
int CO = parseInt((Year-1)/400) - 4
if (CO>0) {MDS = MDS+CO}
 
int X=0
for (int i = 1; i<=(Month - 1); i++)
{
X=X+1
if (X==1) {MDS= MDS+1}
if (X==3) {MDS= MDS+1}
if (X==5) {MDS= MDS+1}
if (X==7) {MDS= MDS+1}
if (X==8) {MDS= MDS+1}
if (X==10) {MDS= MDS+1}
if (X==12) {MDS= MDS+1}
if (X==2)
{
	if (Year % 4  == 0)
	{
		if(Year>1752)
		{
			if (Year % 100 == 0)
			{
			MDS=MDS-2
			if (Year%400==0) {MDS=MDS+1}
			}
			else
			{MDS=MDS-1}
		}
		else
		{MDS=MDS-1}
	}
	else
	{MDS=MDS-2}
}
}
 
 

if (MDS % 7 == 0) {"Saturday"}
if (MDS % 7 == 1) {"Sunday"}
if (MDS % 7 == 2) {"Monday"}
if (MDS % 7 == 3) {"Tuesday"}
if (MDS % 7 == 4) {"Wednesday"}
if (MDS % 7 == 5) {"Thursday"}
if (MDS % 7 == 6) {"Friday"}

- Sanath December 07, 2009 | Flag Reply


Add a Comment
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.

Learn More

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.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More