Siemens Coding Question – Solved

6 Live
How to Attempt? Chocolate Arrangement Alex loves chocolate a lot. His brother Sam gifts him 2^N boxes of chocolate. These boxes are arranged in 2 rows denoted by 2 arrays A and B both of size N. Each box of chocolate contains some number of chocolates which is represented by A[i] and B[i] (for 1 <= i <= N). Alex wants the boxes of chocolate in those 2 rows to be arranged in such a way that the boxes containing an equal number of chocolates are placed at the same index i.e. if A[x] and B[y] are equal, then x should be equal to y. You have to help Alex arrange the rows of boxes such that the maximum number of pairs of equal boxes can be placed at the same index, in the manner that Alex wants. Return the maximum number of pairs of boxes that can be successfully arranged in the manner specified above. Note: You can rearrange the row only by cyclically shifting the row to the left or to the right. A single cyclic shift to the left is an operation that sets A[0] = A[1], A[1] = A[2], ..., A[N-1] = A[0] simultaneously, and a single

Asked in: Siemens

Image of the Question

Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| The supply chain manager at one of Amazon's warehouses is shipping the last con… |
| Determine the highest value after executing n steps on an infinite 2D grid that… |
| Amazon Prime Video is developing a new feature called "Segmentify." This featur… |
| In this new stock prediction game launched on Amazon Games, Player 1 provides P… |
| Amazon operates numerous warehouses, with each warehouse holding inventory[i] u… |
| In Amazon's highly efficient logistics network, minimizing operational overhead… |