Linear Solution O(N) | C++
```\nclass Solution {\npublic:\n    int minimumSeconds(vector& a) {\n\t\tvector b = a;\n\t\tfor(auto i: a){\n\t\t\tb.push_back(i);\n\t\t}\n\t\tvector ans;\n\t\t
```\nclass Solution {\npublic:\n    int minimumSeconds(vector<int>& a) {\n\t\tvector<int> b = a;\n\t\tfor(auto i: a){\n\t\t\tb.push_back(i);\n\t\t}\n\t\tvector<int> ans;\n\t\tint n = b.size();\n\t\tunordered_map<int, int> mapp, xy;\n\t\tint anss = INT_MAX;\n\t\tfor(int i=0; i<n; i++){\n\t\t\tif(mapp.find(b[i]) != mapp.end()){\n\t\t\t\txy[b[i]] = max(xy[b[i]], abs(mapp[b[i]]-i)/2);\n\t\t\t}\n\t\t\tmapp[b[i]] = i;\n\t\t\t\n\t\t}\n\t\tfor(auto i: xy){\n\t\t\tanss = min(anss, i.second);\n\t\t}\n\t\treturn anss;\n    }\n};\n
[]