No array/list allocated short lucky solution
Intuition\n Describe your first thoughts on how to solve this problem. \nThere could be a chance that a number of operations is equal to the max number of opera
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThere could be a chance that a number of operations is equal to the max number of operations required to return one element to it\'s original position.\nOf course this can not be true for every permutations possible, but for this one it is.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe just calculate the number of operations for every single number to return to original position, and returns max number.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n^2)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n\n# Code\n```\nclass Solution {\n    public int reinitializePermutation(int n) {\n        int res = 0;\n        for (int i = 0; i < n; i++) {\n            int k = 1;\n            int p = i;\n            while ((p = (p % 2 == 0 ? p / 2 : n / 2 + (p - 1) / 2)) != i) k++;\n            if (res < k) res = k;\n        }\n        return res;\n    }\n}\n```
['Java']