[Java/C++/Python] From Start to End
Intuition\nWe only need to care the start point and the end point.\n\n                s ----- n\n1 --------------------- n\n1 --------------------- n\n1 ----- e
## **Intuition**\nWe only need to care the start point and the end point.\n```\n                s ----- n\n1 --------------------- n\n1 --------------------- n\n1 ----- e\n```\n<br>\n\n## **Explanation**\nIf start <= end, return the range [start, end].\nIf end < start, return the range [1, end] + range [start, n].\n<br>\n\n## **Complexity**\nTime `O(N)`\nSpace `O(N)`\n<br>\n\n**Java:**\n```java\n    public List<Integer> mostVisited(int n, int[] A) {\n        List<Integer> res = new ArrayList<>();\n        for (int i = A[0]; i <= A[A.length - 1]; ++i)\n            res.add(i);\n        if (res.size() > 0) return res;\n        for (int i = 1; i <= A[A.length - 1]; ++i)\n            res.add(i);\n        for (int i = A[0]; i <= n; ++i)\n            res.add(i);\n        return res;\n    }\n```\n\n**C++:**\n```cpp\n    vector<int> mostVisited(int n, vector<int>& A) {\n        vector<int> res;\n        for (int i = A[0]; i <= A[A.size() - 1]; ++i)\n            res.push_back(i);\n        if (res.size() > 0) return res;\n        for (int i = 1; i <= A[A.size() - 1]; ++i)\n            res.push_back(i);\n        for (int i = A[0]; i <= n; ++i)\n            res.push_back(i);\n        return res;\n    }\n```\n\n**Python:**\n```py\n    def mostVisited(self, n, A):\n        return range(A[0], A[-1] + 1) or range(1, A[-1] + 1) + range(A[0], n + 1)\n```\n
[]