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

| Given an n x m grid, where rows are numbered from 7 to n and columns from 1 to … |
| There are 'N' coders standing in a line, where i denotes the ith position of a … |
| A birthday party was attended by N number of kids, and each kid was given a uni… |
| Given a matrix of size m * n, where m denotes the number of rows (starting with… |
| A traveler is traveling from the city of Zeta to Omega. He starts with X amount… |
| As an operations engineer at Amazon, you are responsible for organizing the dis… |