Google Interview Question for Jr. Software Engineers


Country: United States




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

Do level order traversal. At each level, check if the elements form a palindrome.

- random January 30, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

n must be even.

Use a subroutine , isMirrorImage( Tree a, Tree b )

isSymmetric ( Tree r )
{
	children[]  child = r.children;
	
        for ( s = 0; e = n -1;   )
        {
		isMirrorImage ( child [ s ], child [ e ] );
		s ++; e --;
	}


}

- Anonymous January 17, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <iostream>
#include <vector>
using namespace std;

struct TreeNode
{
	int val;
	vector<TreeNode*> children;
	TreeNode(int val)
	{
		this->val = val;
	}
};

bool IsMirrorImage(TreeNode* t1, TreeNode* t2)
{
	if(t1 == NULL && t2 == NULL)
	{
		return true;
	}
	if(t1 == NULL || t2 == NULL)
	{
		return false;
	}
	bool isMirrorImage = t1->val == t2->val && (t1->children).size() == (t2->children).size();
	int size = (t1->children).size();
	for(int i=0; isMirrorImage == true && i < size; i++)
	{
		isMirrorImage = IsMirrorImage((t1->children)[i], (t2->children)[size-i-1]);
	}
	return isMirrorImage;
}
int main() {
	TreeNode* root1 = new TreeNode(1);
	root1->children.push_back(new TreeNode(2));
	root1->children.push_back(new TreeNode(3));
	TreeNode* root2 = new TreeNode(1);
	root2->children.push_back(new TreeNode(3));
	root1->children.push_back(new TreeNode(2));
	cout<<IsMirrorImage(root1, root2);
}

- Nishagrawa March 17, 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