Questions d'entretien

Entretien pour Entry-level Software Developer

-

IBM

Populate an array of numbers from 1 to N (inclusive). Given two numbers, p and q , if a number in the array is divisible by p print OUT, if a number is divisible by q print THINK. If number is divisible by both p and q, print OUTTHINK. Otherwise, print the number.

Répondre

Réponses aux questions d'entretien

5 réponse(s)

6

seems like a variation of fizzbuzz. Should not be difficult.

Utilisateur anonyme le

1

"#Python Solution from array import * def problem_1(N,p,q): array_1 = array( 'i', range(1,N+1)) for n in array_1: if n % p == 0: print 'OUT' elif n % q == 0: print 'THINK' elif n % p == 0 and n % q==0: print 'OUTTHINK' else: print n problem_1(20,6,8)" Doent't work, think how an else-if sentence is used in compilation :)

Anonymous le

0

the second one is certainly fizzbuzz, you were overthinking.

Utilisateur anonyme le

0

Or is it the actual interview? coding challenge = interview?

does IBM offer another round of interview if you pass this thing? le

0

// C++ Solution void divisibleArray(int array[], int size, int p, int q){ for (int i = 0; i < size; i++){ if (array[i] % p == 0){ cout << "OUT" << endl; }else if (array[i] % q == 0){ cout << "THINK" << endl; } else if (array[i] % p == 0 && array[i] % q == 0){ cout << "OUTTHINK" << endl; } else cout << array[i] << endl; } }

CJ le

Ajouter des réponses ou des commentaires

Pour commenter ceci, connectez-vous ou inscrivez-vous.