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

- Anonymous December 27, 2013 | Flag Reply
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

- billu December 25, 2013 | Flag Reply
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;

- Shi Youying December 26, 2013 | Flag Reply
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;
    }
    
}

- Raspu April 12, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.


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