CareerCup Interview Questions
- 0of 0 votes
AnswersImplement an algorithm to print all valid (e.g., properly opened and closed) combinations of n-pairs of parentheses.
- mosh111 July 16, 2014 in United States
EXAMPLE:
input: 3 (e.g., 3 pairs of parentheses)
output: ()()(), ()(()), (())(), ((()))
This question is from "Cracking the coding interview" (Fourth Edition) and I think that I found mistake in the answer.| Report Duplicate | Flag | PURGE
CareerCup Software Engineer / Developer Algorithm - -3of 3 votes
Answersmultiplication of two numbers without actual multiplication ::
- ace.kartik March 12, 2014 in India
Using vedic mathematics| Report Duplicate | Flag | PURGE
CareerCup Accountant - 1of 1 vote
AnswersDeck of cards :
- ace.kartik March 10, 2014 in India for HD
1) Put the first card on the table and next at the bottom of the deck
2) Repeat the above until all the cards are on table.
3) Pick up the cards and repeat steps 1 and 2.
Find after how many iterations the original order is restored.
For Ex ::
1 2 3
1st iteration - 2 3 1
2nd iteration - 3 1 2
3rd iteration - 1 2 3
so after 3 iterations. Find for n.| Report Duplicate | Flag | PURGE
CareerCup Accountant Algorithm - 0of 0 votes
AnswersWhat is the output of following program:
- godzilla January 04, 2014 in United States for unknown1 #include <stdio.h> 2 3 int r = 1; 4 int numbers[5] = {1, 2, 3, 1, 5 }; 5 6 int main(int argc, char** argv) 7 { 8 #if !defined(_MSC_VER) 9 asm("leal numbers, %esi"); 10 asm("movl $0, %ecx"); 11 asm("movl r, %eax"); 12 asm("label1:"); 13 asm("movl (%esi,%ecx,0x4), %ebx"); 14 asm("imul %ebx, %eax"); 15 asm("addl $1, %ecx"); 16 asm("cmpl $5, %ecx"); 17 asm("jl label1"); 18 asm("mov %eax, r"); 19 #else 20 __asm 21 { 22 LEA ESI, numbers 23 MOV ECX, 0 24 MOV EAX, r 25 label1: 26 MOV EBX, [ESI + ECX * 4] 27 IMUL EAX, EBX 28 ADD ECX, 1 29 CMP ECX, 5 30 JL label1 31 MOV r, EAX 32 } 33 #endif 34 printf("Result= %d\n", r); 35 return 0; 36 }
| Report Duplicate | Flag | PURGE
CareerCup Software Engineer / Developer Assembly - -6of 6 votes
Answersplease tell me about a good website data structure in c++???
- 12024156-061@uog.edu.pk November 13, 2013 in India| Report Duplicate | Flag | PURGE
CareerCup Developer Program Engineer Data Structures - 0of 0 votes
Answersgiven a positive integer n, return an array n x n, and numbers increasing in spiral way using ***recursion***
- skim90 September 27, 2012 in United States
for ex:
n = 4
return
1 2 3 4
12 13 14 5
11 16 15 6
10 9 8 7| Report Duplicate | Flag | PURGE
CareerCup Algorithm - -1of 1 vote
AnswersIn the page 90 of Gayle's cracking the coding interview book, there was a method defined which is used to get the bit at particular position. Method goes like this...
- mooveprince February 20, 2012 in India
boolean getBit(int num, int i) {
return ((num&(1<<i))!=0);
}
Will this works..? if my number is 8 and I want to get the 3rd position, this return a wrong result| Report Duplicate | Flag | PURGE
CareerCup Developer Program Engineer Bit Manipulation - 0of 0 votes
AnswersIn the CrackingTheCodeInterview book solution, CareerCupLibrary - TreeNode, the isBST method is like this:
public boolean isBST() { if (left != null) { if (data < left.data || !left.isBST()) { return false; } } if (right != null) { if (data >= right.data || !right.isBST()) { return false; } } return true; }
But I think this method only checks whether the tree is searchable, it can NOT check whether the tree is balanced. Am I right folks?
- zhangletju March 03, 2011| Report Duplicate | Flag | PURGE
CareerCup Software Engineer / Developer Algorithm
Open Chat in New Window