Salesforce OA
Anonymous User
5213
Feb 13, 2021
Feb 13, 2021
  1. You have an array of numbers from 1 to n. Every number except 1 is repeated twice. Rearrange the array such that every number 'e' is at a distance of 'e' from its duplicate. Also, the array should be the lexographically largest value possible.
    1 <= n <= 40
    Eg : 1 2 2 3 3 4 4 5 5 -> 5 3 1 4 3 5 2 4 2
  2. https://leetcode.com/problems/valid-parenthesis-string/
  3. https://leetcode.com/problems/zuma-game/description/

Can someone please post the solution for 1? I tried backtracking but that obviously timed out for larger test cases.

Comments (4)