## Informatica Interview Question for iOS Developers

Team: interviews
Country: United States
Interview Type: Written Test

Comment hidden because of low score. Click to expand.
3
of 5 vote

Number of 1's for N is Nth fibonacci term
Number of 0's for N is (N-1)th fibonacci term

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

Please clarify your question. Does 0 and 1 counting includes 0/1 as a digit of another number like 10 itself has one 0 ?
If not this question is very straightforward like we can hard-code something like when
n=0 output should be 1 0, n=1, o/p 0 1, n>2 o/p is 1 2

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

//get N iteratively T times
std::string s = "0";
for(int i=1;i<N;i++){
strcat(s,std::to_string(fibonacci(i)));
}
cout<< std::count(s.begin(), s.end(), '0') << " "
<< std::count(s.begin(), s.end(), '1') << endl;

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

C++

``````void printFiboCount(int n)
{
if(n==0)
{
cout<<"1 0"<<endl;
}else if(n==1)
{
cout<<"0 1"<<endl;
}else
{
int n2Ones = 0; // f(0)
int n2Zeros = 1; // f(0)
int n1Ones = 1; // f(1)
int n1Zeros = 0; // f(1)

for (int i = 2; i<n;i++)
{
int newNOnes = n2Ones + n1Ones;
int newNZeros = n2Zeros + n1Zeros;
n2Zeros = n1Zeros;
n2Ones = n1Ones;
n1Zeros = newNZeros;
n1Ones = newNOnes;
}

cout<<(n2Zeros + n1Zeros)<<" "<<(n2Ones + n1Ones)<<endl;
}

}``````

Comment hidden because of low score. Click to expand.

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.

### 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.