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 2020

Persistent Systems India is hiring freshers(FY21) through their online challenges on the AMCAT platform. There are three stages in the first round. At the last stage, you will get two coding questions. I got the exam questions from my friend as he had his exam today. The objective and subjective questions were easy. Among two coding questions, one was easy and the other one was of moderate level.

I am sharing the easy one's question. You may or may not get the same question!!! So practice more.

N.B. For the coding round, you will get many options in languages including C, CPP, JAVA, Python, Pearl, etc.

Question - EASY level

An e-commerce company is planning to give a special discount on all its product to its customers for the Christmas holiday. The company possesses data on its stock of N product types. The data for each product type represents the count of customers who has ordered the given product. If the data K is positive then it shows that the product has been ordered by K customers and is in stock. If the data K is negative then it shows that it has been ordered by K customers but not in stock. The company will fulfill the order directly if the ordered product is in stock if it is not in stock, then the company will fulfill the order after they replenish the stock from the warehouse. They are planning to offer a discount amount A for each product. The discount value will be distributed to the customers who have purchased that selected product. The discount will be distributed only if the decided amount A can be divided by the number of orders for a particular product. 

Write an algorithm for the sales team to find the number of products out of N for which the discount will be distributed.

Input Format

The first line of the input consists of two space-separated integers- numOfProducts and discountAmount, representing the number of different types of products(N) and the discount amount(A) that will be distributed among the customers.

The second line consists of N space-separated integers- order1, order2, ....,ordern representing the current status of the stock for the orders of the respective product types.

Output Format

Print an integer representing the number of products out of N for which the discount will be distributed.

Constraints

0 <= numOfProducts, discountAmount <= 10^5

-10^6 <= orderi <= 10^6

0 <=  i <= numOfProducts

Example

Input

7 18

9 -13 8 -7 -8 18 10 

Output

2

Explanation

The product for which the number of customers will collect the discount amount "3" are types 0 and 5, i.e. 9 and 18 respectively.

So, the output is 2.

You can write your query and solution approach in the comment section. For other test cases and solution comment below. We will send you the solution and it's FREE!!! And don't forget to subscribe to this blog to get the latest hiring news, coding news daily.

Thank you.

Comments

  1. if the discount amount is 0 what will happen?

    ReplyDelete
    Replies
    1. Discount amount may or may not br 0. The only thing you need to consider is whether the discount is applicable or not.

      Delete
    2. I got different questions but thank you for sharing.

      Delete
    3. In which programming language you need the solution?

      Delete
    4. please write us at reply.techdaily@gmail.com

      Delete
    5. please write us at reply.techdaily@gmail.com

      Delete
    6. Bro solution please

      Delete
    7. please write us at reply.techdaily@gmail.com with your preferred programming language

      Delete
    8. I want code in c

      Delete
  2. Replies
    1. CPP solution:

      // persistent solution
      #include
      #include
      using namespace std;

      int main()
      {
      long long int n, a, count = 0;
      cin>>n>>a; // n: number of products a: discount
      long long int products[n];
      for(long long int i = 0; i < n; i++)
      {
      cin>>products[i]; // number of products of type i
      if(products[i] > 0 && a % products[i] == 0)
      count += 1; // count: counting the type of products on which discount is applicable
      }
      cout<<count<<endl;
      return 0;
      }

      Delete
    2. Hello, Thank you for reaching to us. Please send us an email at the given mail id here so that we can send you the solution. Mail Id: reply.techdaily@gmail.com

      Delete
  3. If you have any problem regarding the solution then feel free to reply here.

    ReplyDelete
    Replies
    1. It is not working because header files are not there at the beginning. Otherwise the code is running properly.

      Delete
  4. Hello, Thank you for reaching to us. Please send us an email at the given mail id here so that we can send you the solution. Mail Id: reply.techdaily@gmail.com

    ReplyDelete
  5. Replies
    1. Hello, Thank you for reaching to us. Please send us an email at the given mail id here so that we can send you the solution. Mail Id: reply.techdaily@gmail.com

      Delete
    2. please write us an email at reply.techdaily@gmail.com

      Delete
    3. I need java answer for this can you help me please.

      Delete
  6. I want solution at adinaikwadi8788@gmail.com

    ReplyDelete
    Replies
    1. Please contact us at reply.techdaily@gmail.com to get the solution

      Delete
  7. In need ans inc language asap

    ReplyDelete
    Replies
    1. Contact us at reply.techdaily@gmail.com

      Delete
  8. I need this answer very urgent. Plse write it to my mail kondurlikith@gmail.com

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

      Delete
  10. Please send solutions in c programming

    ReplyDelete
  11. solution in java

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

      Delete
  12. Send me the code in c language

    ReplyDelete
  13. SOLUTION IN PYTHON 3 PLEASE??

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

      Delete
  14. send solution to ayonroy7044@gmail.com

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

      Delete
    2. Bro i need it in c

      Delete
  16. Replies
    1. write us at reply.techdaily@gmail.com

      Delete
  17. Send the code in c to my mail aashishmeduri@gmail.com

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

      Delete
  18. Broo i need help
    Can u plz send this code in python to
    tadekoru_sri@srmap.edu.in
    Plz

    ReplyDelete
    Replies
    1. Pls send the code in python for rsuprajar@gmail.com

      Delete
    2. Write us at reply.techdaily@gmail.com

      Delete
  19. Bro I need code very urgent please send me

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

      Delete
  21. Can you please send the solution in java on siyaverma0786@gmail.com

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

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

      Delete
    2. Need immediately answer please

      Delete
    3. write us at reply.techdaily@gmail.com

      Delete
  23. Replies
    1. Write us at reply.techdaily@gmail.com

      Delete
  24. I want this question solution in php
    Please share on 18793pooja@gmail.com

    ReplyDelete
  25. I need code in python
    Please mail on alexsumit999@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.