Computer Associates Interview Question for Software Engineer / Developers


Country: United States




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

put 'a' in array['a' - 'a']; 'b' in array['b'-'a'],etc....

- Anonymous July 03, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

U r actually using the ascii values implicitly.. It's not allowed right?

- Myself July 03, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

The statement "WITHOUT using the ascii values" probably means you can't use the ascii value directly, especially with the constraint of an array of size 32. Since the poster hasn't clarified the issue, it is probably safe to assume you can use the ascii values to determine an indirect index. Especially since you only have to worry about lower case. Which means you only need 'z'-'a'+1 slots or 26 slots. So an array of size 32 is going to be more than sufficient to track lowercase letters. So something like the following pseudo-code should do the trick.

for (char* c = buffer; c < 'buffer end'; ++c ) {

    array[*c-'a']++;
    ++c;
}

This also assumes you're using single byte characters, which again since the poster hasn't specified is probably a safe assumption to make, but... depends on whomever was the originator of the question.

- Developer July 04, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

we can use hash table.

- Anonymous July 03, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I too thought for it, but they asked to use a 32 length array..!!
If hash table is allowed, then its best.

- Ayush July 04, 2011 | Flag


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