## Oracle Interview Question for Applications Developers

• 0

Country: India

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

Formula is:
((N-i)! Up to i=K)*((N-k)^(N-i)) where i Is iterating from 0 to N

Comment hidden because of low score. Click to expand.
0

Could you please confirm me whether this formula is the correct solution for this problem

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

8.void main()
9.{
10. int i, n, sum = 0;
11. int *a;
12.
13. printf("Enter the size of array A \n");
14. scanf("%d", &n);
15. a = (int *) malloc(n * sizeof(int));
16. printf("Enter Elements of First List \n");
17. for (i = 0; i < n; i++)
18. {
19. scanf("%d", a + i);
20. }
21. </* Compute the sum of all elements in the given array */
22. for (i = 0; i < n; i++)
23. {
24. sum = sum + *(a + i);
25. }
26. printf("Sum of all elements in array = %d\n", sum);
27.}

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

8.void main()
9.{
10. int i, n, sum = 0;
11. int *a;
12.
13. printf("Enter the size of array A \n");
14. scanf("%d", &n);
15. a = (int *) malloc(n * sizeof(int));
16. printf("Enter Elements of First List \n");
17. for (i = 0; i < n; i++)
18. {
19. scanf("%d", a + i);
20. }
21. </* Compute the sum of all elements in the given array */
22. for (i = 0; i < n; i++)
23. {
24. sum = sum + *(a + i);
25. }
26. printf("Sum of all elements in array = %d\n", sum);
27.}

Comment hidden because of low score. Click to expand.
0
of 2 vote

Answer: Nx(N-1)x...x(N-K+1)x(N-K)^(L-K) - (the number of posibilities where at least one song is not played).

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

Answer: Nx(N-1)x...x(N-K+1)x(N-K)^(L-K) - (the number of posibilities where at least one song is not played).

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

The following cases must be eliminated.
Case 1) Only K songs are present => (NcK)xKx(K-1)...x2
Case 2) Only K+1 sings are present =>(Nc(K+1)) x(K+1)xK...x2
......
.....
Case N-K) Only N-1 songs are present => N x (N-1)x(N-2)x(N-K)x(N-1-K)^(L-K)

Let the sum be S
The answer is Nx(N-1)x...x(N-K+1)x(N-K)^(L-K) - S

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

Assuming order of play doesn't result in different playlists the number of playlists will be (nCk)*n^(l-k). If order matters this will be (n!/k!)*n^(l-k).

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

NCK * K! * (L-K)C(N-K) * (N-K)! * (N-K)^(L-N)

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

(N!/(N-K)!) * (N-K)^(L-K+1) assuming L > K and N >= K

For the first K songs, we have a decreasing list of possibilities
1st song - N
2nd song - (N-1)
3rd song - (N-2)
...
ith song (i < K) - (N-i)
Kth song - (N-K)

After this, for each song, one of the songs from the earlier choice is also valid thus always ensuring that the available songs is (N-K) for the remaining (L-K) songs

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

In the original task there are constrains:
N lies between 1 and 100, inclusive.
L lies between 0 and N, inclusive.
K lies between N and 100, inclusive.

So K≥N. The Nx(N-1)x...x(N-K+1)x(N-K)^(L-K) formula is incorrect.
I thin the formula is incorrect even without these constraints.

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

- N lies between 1 and 100, inclusive.
- L lies between 0 and N, inclusive.
- K lies between N and 100, inclusive.

So K≥N, the formula Nx(N-1)x...x(N-K+1)x(N-K)^(L-K). I think it is incorrect even without these constrains.

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

I think it will be N * (N-1)CK * (N-K)^(L-K+1)

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.

### 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.