Join Regular Classroom : Visit ClassroomTech

Nagarro Question Solved | Kung Fu Panda Training | Codewindow.in

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

Nagarro Question Solved | Kung Fu Panda Training | Codewindow.in

Po is receiving training from master Shifu for his big fight with Tai Lung scheduled for the upcoming week. Apart from his physical training, Master Shifu also decides to train him mentally, by giving him puzzles to solve. 

 

He gives Po a puzzle an array of N numbers and tells Po that at a time in one move, Po can choose an element P from the array, and delete that element along with all the elements with value P+1 and P-1. For this move, he will get P dumplings. As dumpings are Po's favorite, help Po in finding the maximum number of dumplings he can get. 

 

Output Specification:

Input1: N size of array

Input2: The array of numbers

 

Output Specification:

Return the maximum number of dumplings Po can get

 

Example1:

Input1: 5

Input2: {3,3,4,5,4}

Output: 11

 

Explanation:

First Po can choose the 1st element 3 which is deleted along with the elements with value 4.So,the array becomes {3,5} and he gets 3 points.Next he chooses 3 again, so the array becomes {5} and he gets 3 points,which makes his total to be 6 points.Lastly, as only 1 element is remaining, he can delete it to get 11 dumplings.

 

Example2:

Input1: 5

Input2: {1,2,3,4,5}

Output: 9

Explanation:

1st step: choose 1, array becomes: {3,4,5},Points:1

2nd step: choose 3, array becomes: {5},Points:1+3=4

3rd step: choose 5, array becomes: {},Points:1+3+5=9

Input:

5
{3,3,4,5,4}

Output:

11

Python

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

def dumplings(input1, input2):
	maximum = 0;
	for i in range(input1) :
		maximum = max(maximum, input2[i])
	count = [0] * (maximum  + 1)
	for i in range(input1) :
		count[input2[i]] += 1
	result = [0] * (maximum  + 1)
	result[0] = 0
	for num in range(1, maximum + 1):
		k=max(num - 1 - 1, 0)
		result[num] = max(result[num-1], num * count[num] + result[k])
	return result[maximum]
	
input1 = 5
input2 = [1,2,3,4,5]
print(dumplings(input1, input2))
input1 = 5
input2 = [3,3,4,5,4]
print(dumplings(input1, input2))

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