Search This Blog
Here in this blog, one will get the latest technical news like - hiring challenges, coding competitions of different companies, opportunities for students, scholarships, and many more.
Featured
- Get link
- X
- Other Apps
PERSISTENT SYSTEMS INDIA HIRING CHALLENGE - FY21 - CODING CHALLENGE 2021
The first step to get hired by the Persistent Systems is their AMCAT online assessment. In this assessment you will get two coding question along with different sections like aptitude, verbal etc. To solve the coding problem you will get multiple programming language options - C, C++, Python etc.
In this blog I am sharing one of their online coding challenge question. You may or may not get the same question so practice more.
Question - Easy/ Medium Level
A pizza shop makes vegan pizzas as well as meat based pizzas. The customers place N orders at the shop and their order number gets printed on their bill. The shop displays k out of N both-vegan and meat based pizza orders on their display screen at a single time. The pizza shop is very famous and receives many orders. So to avoid confusion, the vegan pizza orders are displayed as a positive order number and the meat based pizza orders are displayed as a negative order number. All the orders are delivered in the order in which they are displayed on the screen. Each time a displayed order is ready, it is then removed from the display screen and the next order is added to the display at the end. A couple has come to eat pizza with their child Billy . Billy is a very naughty child and to keep him busy, his parents tell him to makes a list of the first meat based pizza order number present in each set of k orders displayed on the shop’s display screen.
Write an algorithm to help Billy make a list of the first meat based pizza order numbers displayed on the screen each time an order is delivered to a customer.
Input
The first line of the input consists of two space-separated integers – numOfOrders and size, representing the total number of orders placed(N) and the number of orders displayed on the screen (K), respectively. The second line consists of N space-separated integers representing the vegan pizza and meat based pizza order numbers of the orders placed by the customers.
Output
Print a list of space-separated integers representing the first meat based pizza order of every k orders displayed on the screen each time an order is delivered to a customer and print 0 if the screen does not display any meat based pizza order.
Constraints
0 <= numOfOrders <= 106
0 <= size <= numOfOrders
-109 <= ordersNum <= 109
, where orderNum represents the order numbers of the orders placed
Example
Input
6 3
-11-2 19 37 64-18
Output:
-11 -2 0-18
Explanation:
Step1: At the time of the first display, the order numbers displayed are [-11,-2,19].
So, the first displayed meat based pizza order number is -11.
Step2:At the time of the next display, the order numbers displayed are[-2,19,37]
So, the first displayed meat based pizza order number is -2.
Step3:At the time of the next display, the order numbers displayed are[19,37,64].
Since no meat based pizza order is displayed, the output is 0.
Step4:Similarly,at the time of the next display, the order numbers displayed are[37,64,-18].
So, the first displayed meat based pizza order number is -18.
So, the output is [-11, -2, 0,-18].
TESTCASE: Testcase-1:
Input:
6 3
-11 -2 19 37 64 -18
Expected Return Value:
--11 -2 0-18
You can write your query and solution approach in the comment section. For the solution you can also contact us through our contact details. We will send you the solution and it is FREE. Do not forget to subscribe this blog to get latest hiring details.
Thank you.
- Get link
- X
- Other Apps
Comments
Popular Posts
Internship Update | June 2021 | Batch 2021 and 2022
- Get link
- X
- Other Apps
Send this solution to me please.
ReplyDeletePlease write us at reply.techdaily@gmail.com
Deletedid you get the solution?
Deletei want sollution
DeleteCan you post the solution here
ReplyDeletePlease write us at reply.techdaily@gmail.com
DeleteI need the solution for the above problem admin, can you please help me?
ReplyDeletePlease write us at reply.techdaily@gmail.com
DeleteCode need fast
DeletePlease send the solution
ReplyDeleteI need answer for this
ReplyDeleteI need answer
ReplyDeletei need the solution for the above question
ReplyDeletePls send solution
ReplyDeleteif __name__ == "__main__":
ReplyDeletenumOfOrders, size = map(int, input().split())
ordersNum = list(map(int, input().split()))
mpizza = []
for i in range(numOfOrders - size + 1):
found = 0
for j in range(i, i + size):
if(ordersNum[j] < 0):
mpizza.append(ordersNum[j])
found = 1
break
if(found == 0):
mpizza.append(0)
print(mpizza)
don't forget to apply indentation.
DeleteWhich language
DeleteNot getting the output
DeleteSolution?
ReplyDeletePlease write us at reply. techdaily@gmail.com
DeleteSend me solution
ReplyDeleteCan i get the solution please
ReplyDeleteSend me solution
ReplyDeletePlease post me the solution as soon as possible, within 5 mins
ReplyDeletePlease send the code
ReplyDeletePlease send us an email at reply.techdaily@gmail.com
DeleteI want code
DeletePlease send the code
ReplyDeletePlease write us at reply.techdaily@gmail.com
DeleteI need the code pls post me
ReplyDeleteCode
ReplyDeletePLEASE SND SOLUTION AT ANKURSHAR007@GMAIL.COM
ReplyDeletePlease send the solution asap barindersran2110@gmail.com
DeletePls Give me the whole code of this question as a solution a ASAP
ReplyDeleteGive me solution on bhombemayuresh9@gmail.com
ReplyDeleteplease send solution on bhagyashrikshirsagar1@gmail.com
ReplyDeletePlease write us to reply.techdaily@gmail.com
Deletesend java solution to thaparyakash@gmail.com
ReplyDeletecan you please send the answer fast??
ReplyDeletePlease write us at reply. techdaily@gmail.com
Deletesend the solution
ReplyDeleteall.the.way.up2311@gmail.com
pls send solution to jain.shreya70@yahoo.com
ReplyDeleteCan send the solution to sharathroy92@gmail.com
ReplyDeletesend the solution to kharbanda.aryaman10@gmail.com
ReplyDeleteSend solution at vastyash@gmail.com
ReplyDeletePlease send us an email at reply.techdaily@gmail.com
Deleteplz send solution at nishushrirao21@gmail.com
ReplyDeleteplease answer this
ReplyDeleteSend me the code
ReplyDeleteomkarsonone1@gmail.com
Code please
ReplyDeletePlease send code
ReplyDeletecode?
ReplyDelete