Citrix System Inc Interview Question for Software Engineer / Developers






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

Total combinations = 20! / (10! * 10!)

public static void perm(char[] w,int d)
        {
            
            if (d == w.length)
                System.out.println(count++ + ". " + new String(w) );
                
            char lastSwap = ' ';
                for(int i=d; i<w.length; i++)
                {
                    if(lastSwap == w[i])
                        continue;
                    else
                        lastSwap = w[i];
                    
                    w = swap(w,d,i);
                    perm(w,d+1);
                    w = swap(w,d,i);
                }
            
        }

        public static char[] swap(char[] w, int x, int y)
        {
            char t = w[x];
            w[x] = w[y];
            w[y] = t;
            return w;
        }

- RV February 11, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A0,A1...A10 11 possibilities
B0,B1...B10 11 possibilities
altogether 121 possibilities-1=120

- anonymous December 24, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Identical A's and B's?

Combination of A's and B's can be a string of 2 letters or more (AB, ABB or ABBAABB). If it is a string of 5 letters then there is 2! x 2! x 2! x 2! x 2! = 2x2x2x2x2 or 2^5 combination. If 6 letter string then there is 2^6 combination and so on.

- Anonymous December 25, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#define SIZE 21
void print(int a,int b,char str[])
{
if(a==0&&b==0)
{
str[SIZE-1]='\0';
puts(str);
return;
}
if(a!=0)
{
str[SIZE-1-a-b]='A';
print(a-1,b,str);
}
if(b!=0)
{
str[SIZE-1-a-b]='B';
print(a,b-1,str);
}
return;
}

call print(10,10,str)

- um December 25, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void main(String[] args) {
        int noOfA = 3;
        int noOfB = 3;
        generateCombi(noOfA, noOfB, "");

    }

    public static void generateCombi(int noOfA, int noOfB, String s) {
        if (noOfA == 0 && noOfB == 0)
            System.out.println(s);
        if (noOfA > 0) {
            generateCombi(noOfA - 1, noOfB, s + "A");
        }

        if (noOfB > 0) {
            generateCombi(noOfA, noOfB - 1, s + "B");
        }

}

- Ashish December 27, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

nice solution

- ano January 26, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

We dont need extra memory to do this.

void func(int no_A,int no_B) {

if(no_A) {
printf("A");
func(no_A-1,no_B);
}
if(no_B) {
printf("B");
func(no_A,no_B-1);
}
}

- madhav February 04, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

sorry the above algo doesnt work!

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

There are n choose r ways of choosing r items from n items. In this case given 20 items, he is expecting nc0+nc1+nc2+..ncn = 2^n.

- Anonymous February 06, 2011 | 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