Join Regular Classroom : Visit ClassroomTech

Nagarro Question Solved | Piggy Bank | Codewindow.in

Company Based – Codewindow

Interview Questions
1. TCS Technical Questions
2. CTS Technical Questions
3. Infosys Technical Questions
4. Capgemini Technical Questions
5. IBM Technical Questions
6. Wipro Technical Questions
7. Accenture Technical Questions
8. Deloitte Technical Questions
9. MindTree Technical Questions
10. NTT Data Technical Questions
11. Persistent Technical Questions
12. Hexaware Technical Questions
13. ZOHO Technical Questions
14. HCL Technical Questions
15. Genpact Technical Questions
16. udostres Technical Questions
17. samsung research Technical Questions
18. Media.net Technical Questions
19. Tejas Network Technical Questions
20. Kantar Technical Questions
21. Itron Technical Questions
22. Fractal Analyst Technical Questions
23. Lexmark International Technical Questions
24. Infeneon Technologies Technical Questions
25. Razorpay Technical Questions
26. payu Technical Questions
27. Navi Technical Questions
28. Tata Cliq Technical Questions
29. Grab Technical Questions
30. Schlumberger Technical Questions
31. Latenview Analytics Technical Questions
32. GreayB Technical Questions
33. Tally solution Technical Questions
34. Amagi Technical Questions
35. HFCL Technical Questions
36. Slice Technical Questions
37. Larsen & Turbo Technical Questions
38. Zenser Technical Questions
39. Siemens Technical Questions
40. Exon Movie Technical Questions
41. Gupshup Technical Questions
42. Smart cube Technical Questions
43. Celebal Tech Technical Questions
44. Teg Analytics Technical Questions
45. Commvault Systems Technical Questions
46. Incuture Technical Questions
47. Tiger Technical Questions
48. Bridgei2i Technical Questions
49. code nation Technical Questions
50. DE Show Technical Questions
51. Amazon Technical Questions
52. Flipkart Technical Questions
53. Morgan Stanly Technical Questions
54. duutsche bank Technical Questions
55. textas Technical Questions
56. pwc Technical Questions
57. salesforce Technical Questions
58. optum Technical Questions
59. Nvidia Technical Questions
60. Itc Infotech Technical Questions
61. linkedin Technical Questions
62. Adobe Technical Questions

Nagarro Question Solved | Piggy Bank | Codewindow.in

Daniel has 2 piggy banks. A bigger one and a smaller one. He has divided the bigger piggy bank in X slots and smaller piggy bank in Y slots, X > Y.

He has some money deposited in both of them. He chooses Y slots from the bigger piggy bank and transfers their money to Y slots of smaller piggy bank in respective order. He wants that the amount in slot n+1 should always be greater tha or equal to that in the slot n,of the smaller piggy bank, after the transfer from the bigger piggy bank. You have to help Daniel to count the number of ways he can transfer the money.

Input Specification:

Input1: Number of slots in bigger piggy bank.

Input2: Number of slots in smaller piggy bank.

Input3: Amounts in slots of bigger piggy bank.

Input4: Amounts in slots of smaller piggy bank.

Output Specification:

Return the number of ways to transfer amount.

Example 1:

Input1: 5

Input2: 3

Input3: {1,5,2,4,7}

Input4: {7,9,6}

Output: 4

Explanation:

The slots from the bigger piggy bank can be selected as {1,2,7},{1,4,7},{5,4,7} and {2,4,7} i.e, 4 ways to transfer the amount.

Example 2:

Input1: 4

Input2: 2

Input3: {7,7,7,7}

Input4: {3,4}

Output: 6

Explanation:

The slots from the bigger piggy bank can be selected as two 7s from the slots as {1st,2nd}, {1st,3rd},{1st,4th},{2nd,3rd},{2nd,4th},{3rd,4th}; i.e 6 ways to transfer the amount.

Input:

4
2
{7,7,7,7}
{3,4}

Output:

6

JAVA

//https://codewindow.in
//join our telegram channel @codewindow

import java.util.*;
import java.io.*;


public class CodeWindow {
	static int piggyBank(int input1,int input2, int[] input3, int[] input4)
	{
	  int ans[]=new int[1];
	  int data[]=new int[input2];
	  comb(input3,input1,input2,0,data,0,ans);

	  return ans[0];
	}


	static void comb(int arr[], int n, int r, int index,
	int data[], int i,int ans[])
	{
	  if (index == r)
	  {
	      for (int j=0; j<r; j++);
	          ans[0]++;
	      return;
	  }
	if (i >= n)
	  return;
	data[index] = arr[i];
	comb(arr, n, r, index+1, data, i+1,ans);
	comb(arr, n, r, index, data, i+1,ans);

	}

	public static void main(String[] args) {
		int input1 = 4, input2 = 2;
		int input3[] = {7,7,7,7};
		int input4[] = {3,4};
		int result = piggyBank(4,2,input3,input4);
		
		System.out.println(result);
		
		
	}

}

Nagarro Solved

Automata Fixing

      

Popular Category

Hot Topics

Company Based – Codewindow

Interview Questions
1. TCS Technical Questions
2. CTS Technical Questions
3. Infosys Technical Questions
4. Capgemini Technical Questions
5. IBM Technical Questions
6. Wipro Technical Questions
7. Accenture Technical Questions
8. Deloitte Technical Questions
9. MindTree Technical Questions
10. NTT Data Technical Questions
11. Persistent Technical Questions
12. Hexaware Technical Questions
13. ZOHO Technical Questions
14. HCL Technical Questions
15. Genpact Technical Questions
16. udostres Technical Questions
17. samsung research Technical Questions
18. Media.net Technical Questions
19. Tejas Network Technical Questions
20. Kantar Technical Questions
21. Itron Technical Questions
22. Fractal Analyst Technical Questions
23. Lexmark International Technical Questions
24. Infeneon Technologies Technical Questions
25. Razorpay Technical Questions
26. payu Technical Questions
27. Navi Technical Questions
28. Tata Cliq Technical Questions
29. Grab Technical Questions
30. Schlumberger Technical Questions
31. Latenview Analytics Technical Questions
32. GreayB Technical Questions
33. Tally solution Technical Questions
34. Amagi Technical Questions
35. HFCL Technical Questions
36. Slice Technical Questions
37. Larsen & Turbo Technical Questions
38. Zenser Technical Questions
39. Siemens Technical Questions
40. Exon Movie Technical Questions
41. Gupshup Technical Questions
42. Smart cube Technical Questions
43. Celebal Tech Technical Questions
44. Teg Analytics Technical Questions
45. Commvault Systems Technical Questions
46. Incuture Technical Questions
47. Tiger Technical Questions
48. Bridgei2i Technical Questions
49. code nation Technical Questions
50. DE Show Technical Questions
51. Amazon Technical Questions
52. Flipkart Technical Questions
53. Morgan Stanly Technical Questions
54. duutsche bank Technical Questions
55. textas Technical Questions
56. pwc Technical Questions
57. salesforce Technical Questions
58. optum Technical Questions
59. Nvidia Technical Questions
60. Itc Infotech Technical Questions
61. linkedin Technical Questions
62. Adobe Technical Questions

We Love to Support you

Go through our study material. Your Job is awaiting.

Recent Posts
Categories