Explained - using map || very simple and easy to understand solution
Inution \nWe need to find out the number whose occurance is very frequent and max elements between its two occurance should be minimun.\n\n# Approach\n1. Here w
# Inution \nWe need to find out the number whose occurance is very frequent and max elements between its two occurance should be minimun.\n\n# Approach\n1. Here we need to find the max number of elements in between two occurance of same element for each value.\n2. Then find the element where the maxDiff is minimum.\n3. Return the (min + 1)/2 as the answer.\n\nBasically for each two occurance of an element with n number of different elements in between them. Then it will take (n+1) second to make all middle element equal to the boundary element.\nfor ex: [1, 2,3,4, 1]\nHere in b/w two occurance of 1\'s we have 3 different numbers.\nNow after 1st operation : [ 1, 1,3,1, 1]\nAfter 2nd operation: [1, 1,1,1, 1]\n\nWe needed (n+1)/2 = (3+1)/2 = 2 operations make all element equal.\n\nNote : To handle rotation case, I have executed the for loop two times.\n\n\n# Code\n```\nint minimumSeconds(vector<int>& nums) {\n    int ans = INT_MAX, n = nums.size();\n    unordered_map<int, int> lastSeen, maxDiff;\n    for(int i = 0; i < n; ++i){\n        if(lastSeen.find(nums[i]) != lastSeen.end()){\n            maxDiff[nums[i]] = max(maxDiff[nums[i]], i - lastSeen[nums[i]] - 1);\n        }\n        lastSeen[nums[i]] = i;\n    }\n    for(int i = 0; i < n; ++i){ //to handle rotation repeat the same once again\n        maxDiff[nums[i]] = max(maxDiff[nums[i]], (i - lastSeen[nums[i]] -1 + n )%n );\n        lastSeen[nums[i]] = i;\n    }\n    \n    for(auto [k, v]: maxDiff) ans = min(ans, v);\n    return (ans + 1)/2; \n}\n```\n---\n\n<b>Here is an article of my last interview experience - A Journey to FAANG Company, I recomand you to go through this to know which all resources I have used & how I cracked interview at Amazon:\nhttps://leetcode.com/discuss/interview-experience/3171859/Journey-to-a-FAANG-Company-Amazon-or-SDE2-(L5)-or-Bangalore-or-Oct-2022-Accepted\n\n---
['C++']