Global Scholar Interview Question for Developer Program Engineers






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

Hope this code works.


int main()
{
int n,a[4]={0}, i=3, b[4]={0}, flag=1;
scanf("%d",&n);
while(n>0)
{
a[i--]=n%10;
n=n/10;

}
for(i=0;i<4;i++)
b[a[i]]++;
for(i=0;i<4;i++)
if(a[i]!=b[i])
{
flag=0;
break;
}
if(flag)
printf("given number has same property");
else printf("given number doesn't possess the property");


}
}}}

- Vanathi August 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

vamathi is right i hope

- sivavikneshs August 08, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

it seems a little confusing, can u plz give another example

- Anonymous August 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think counting the frequency of each 'number' in given number .Representing all missing numbers by '0' at their respective index and others with their frequencies(number of times they have occurred in given number)..

Please correct me if I am missing somethingg

- freesoul August 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

what about using String?

- KevinJom August 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

How about using String…

- KevinJom August 07, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

interviewer told me to use only number

- vicky August 07, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

HOW ABOUT THIS BELOW:
public static boolean numberCheck(int num){
String numStr = ""+num; //先把这个数字包装到字符串中,以方便用每个字符查找
if(numStr.length()>10){
return false; //显然如果这个数是十一位数或者更大,根本不能满足
}
//char[] numChars = numStr.toCharArray();
for(int i =0;i<numStr.length();i++){
int times = Integer.parseInt(numStr.substring(i,i+1)); //i在num出现的次数
int count =0;
for(int j = 0;j<numStr.length();j++){
if((String.valueOf(i).equals(String.valueOf(numStr.charAt(j))))){
++count;
}
}
if(times!=count){
return false;
}
}
return true;
}

- KevinJom August 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int indexproperty_check(int data)
{
int data1=data;
int a[9]={0};
int digit_size=0;
while(data1)
{
a[data1%10]++;
data1=data1/10;
digit_size++;
}
for(int i=0;i<digit_size;i++)
{
data1 = a[i]+data1*10;
}
if(data1==data)
{
cout<<"Index property is satisfied";
return 1;
}
else
{
cout<<"Index property is not satisfied";
return 0;
}
}

- CPS March 31, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static boolean isStructure(int input){
		int divider=1;
		int digits=0;
		int max=Integer.MIN_VALUE;
		while(input/divider>0){

			if((input/divider)%10>max)
				max=(input/divider)%10;
			divider*=10;
			digits++;
		}
		if(max>=digits)
			return false;
		int a[]= new int[digits];
		int inputcopy=input;
		while(inputcopy>0){
			a[inputcopy%10]++;
			inputcopy/=10;
		}

		int result=0;
		int i=0;
		while(--digits>=0){
			result+=a[i++]*Math.pow(10,digits);
		}
		return result==input;
	}

	public static void main(String args[]) {
		for(int i=0; i<10000;i++){
			if(Numbers.isStructure(i))
			System.out.println(i);
		}
	}

- talentX June 28, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <iostream>
#include <conio.h>
using namespace std;
#include <math.h>
#include <vector>

int _tmain(int argc, _TCHAR* argv[])
{
	int n;
	cin >> n;
	
	/* Find Number of Digits in the Input Number */
	int NumOfDig = ceil(log10(n));

	/* Vector to maintain the Value of the Input Digit in the Index */
	vector<int> arr(NumOfDig);

	/* Vector to maintain Number of Occurences of a value (0-9) in the Input Number */
	vector<int> NumOfOccurences(10);

	int counter = NumOfDig - 1;
	while(counter >= 0)
	{
		int rem = n % 10;		
		arr[counter] = rem;
		NumOfOccurences[rem] += 1;
		n /= 10;
		counter--;
	}

	vector<int>::iterator it;
	int index;
	for(index = 0, it = arr.begin(); it != arr.end(); it++, index++)
	{
		if((*it) != NumOfOccurences[index])
		{
			cout << endl << "NO";
			_getch();
			return 0;
		}
	}
	cout << endl << "YES";
	_getch();
	return 0;
}

- randomlyideas December 14, 2012 | 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