Google Interview Question for Software Engineers


Country: United States




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

Hi All,

Question is about line segments not the lines. Each line segment is represented with the start and their end points and the intercept point on the axis. And another boolean to represent if the line segment is horizontal or vertical.

Example: 10 20 5 V represents a line which is vertical and its x-intercept is 5 and start from 10 and ends at 20 ie., points are (5, 10) (5, 20) represents the line

- uj.us October 07, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int findNumOfSquares(int h, int v){
 int result; 
 if(h < 2 && v < 2 ){
   return result;
 }
 else{
  result =  1  + findNumOfSquares(v-2,h-2)
}
return result;
}

- novastorm123 October 16, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

h = int(input("Enter number of horizontal lines : "))
v = int(input("Enter number of vertical lines : "))
result = 0
small = min(h,v)
for i in range(-1,small):
result += ((h-i)*(v-i))
print("Number of squares : ", result)

- can it be simplified? October 04, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

h = int(input("Enter number of horizontal lines : "))
v = int(input("Enter number of vertical lines : "))
result = 0
small = min(h,v)
for i in range(-1,small):
    result += ((h-i)*(v-i))
print("Number of squares : ", result)

- can it be simplified? October 04, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

h = int(input("Enter number of horizontal lines : "))
v = int(input("Enter number of vertical lines : "))
result = 0
small = min(h,v)
for i in range(-1,small):
    result += ((h-i)*(v-i))
print("Number of squares : ", result)

- can_it_be_simplified October 04, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

h = int(input("Enter number of horizontal lines : "))
v = int(input("Enter number of vertical lines : "))
result = 0
small = min(h,v)
for i in range(-1,small):
    result += ((h-i)*(v-i))
print("Number of squares : ", result)

- can it be simplified? October 04, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

h= int(input(“Enter the number of horizontal lines:”))
v= int(input(“Enter the number of vertical lines:”)
def maxsquares(h,v):
squares=(h-1)*(v-1)
return squares
maxsquares(h,v)

- Anonymous October 05, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

int findNumberOfSquares(int h, int v) {
	int min = Math.min(h,v);
	int num = min / 2;
	return min;

}

- Dave October 09, 2019 | 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