Skip to main content

Featured

Walmart Sparkplug 2024

Walmart Global Tech is a global retail company, based on US. Walmart has its branches in India. In recent it has started a hackathon named Sparkplug 2024 to provide internship opportunities to the students in Walmart Global Tech India in Summer 2024. About Sparkplug 2024: Sparkplug 2024 is a hackathon to join Walmart Global Tech India as an Intern in Summer 2024. The hackathon has been designed for the coders who love to solve challenges and want to experience the work culture at Walmart India based in Bangalore/ Gurgaon/ Chennai. The top 100 performers of the hackathon will be given an internship to the various development teams of Walmart at a monthly stipend of 1-1.1 Lakh INR. Eligibility Criteria: The hackathon is opened to the students from a selected list of 34 engineering colleges across India who are pursuing the below degrees. [Note: the list of college is shared in the registration page] BE/ B.Tech. full-time programs - Batch of 2025 i.e., students currently in their 3rd

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. 


Comments

  1. Send this solution to me please.

    ReplyDelete
  2. Replies
    1. Please write us at reply.techdaily@gmail.com

      Delete
  3. khanhero694@gmail.comAugust 29, 2021 at 12:01 AM

    I need the solution for the above problem admin, can you please help me?

    ReplyDelete
  4. i need the solution for the above question

    ReplyDelete
  5. if __name__ == "__main__":
    numOfOrders, 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)

    ReplyDelete
  6. Replies
    1. Please write us at reply. techdaily@gmail.com

      Delete
  7. Please post me the solution as soon as possible, within 5 mins

    ReplyDelete
  8. Replies
    1. Please send us an email at reply.techdaily@gmail.com

      Delete
  9. Please send the code

    ReplyDelete
    Replies
    1. Please write us at reply.techdaily@gmail.com

      Delete
  10. I need the code pls post me

    ReplyDelete
  11. PLEASE SND SOLUTION AT ANKURSHAR007@GMAIL.COM

    ReplyDelete
    Replies
    1. Please send the solution asap barindersran2110@gmail.com

      Delete
  12. Pls Give me the whole code of this question as a solution a ASAP

    ReplyDelete
  13. Give me solution on bhombemayuresh9@gmail.com

    ReplyDelete
  14. please send solution on bhagyashrikshirsagar1@gmail.com

    ReplyDelete
    Replies
    1. Please write us to reply.techdaily@gmail.com

      Delete
  15. send java solution to thaparyakash@gmail.com

    ReplyDelete
  16. can you please send the answer fast??

    ReplyDelete
    Replies
    1. Please write us at reply. techdaily@gmail.com

      Delete
  17. send the solution
    all.the.way.up2311@gmail.com

    ReplyDelete
  18. pls send solution to jain.shreya70@yahoo.com

    ReplyDelete
  19. Can send the solution to sharathroy92@gmail.com

    ReplyDelete
  20. send the solution to kharbanda.aryaman10@gmail.com

    ReplyDelete
  21. Send solution at vastyash@gmail.com

    ReplyDelete
    Replies
    1. Please send us an email at reply.techdaily@gmail.com

      Delete
  22. plz send solution at nishushrirao21@gmail.com

    ReplyDelete
  23. Send me the code
    omkarsonone1@gmail.com

    ReplyDelete

Post a Comment

If you have any doubts feel free to write here. One of our executives will reach back to you.

Popular Posts