Given a list of 24-hour clock time points in <strong>&quot;HH:MM&quot;</strong> format, return <em>the minimum <b>minutes</b> difference between any two time-points in the list</em>.
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre><strong>Input:</strong> timePoints = ["23:59","00:00"]
<strong>Output:</strong> 1
</pre><p><strong class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> timePoints = ["00:00","23:59","00:00"]
<strong>Output:</strong> 0
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>2 &lt;= timePoints.length &lt;= 2 * 10<sup>4</sup></code></li>
	<li><code>timePoints[i]</code> is in the format <strong>&quot;HH:MM&quot;</strong>.</li>
</ul>

class Solution:
    def findMinDifference(self, timePoints: List[str]) -> int:
        given_times = defaultdict(int)
        for t in timePoints:
            given_times[t] += 1

        all_times = []
        hours = [h for h in range(1, 25)]

        def get_hours(h1, h2):
            idx1  = hours.index(h1)
            idx2 = hours.index(h2)
            cnt = 0
            while idx1 != idx2:
                idx1 = (idx1 + 1) % 24
                cnt += 1
            
            return cnt

        for hh in range(24):
            for mm in range(60):
                str_hh = str(hh) if hh > 9 else f'0{hh}'
                str_mm = str(mm) if mm > 9 else f'0{mm}'
                all_times.append(f'{str_hh}:{str_mm}')

        def diff(t1: str, t2:str) -> int:
            hh_t1, mm_t1 = int(t1[:2]), int(t1[3:])
            hh_t2, mm_t2 = int(t2[:2]), int(t2[3:])

            hh_t1 = 24 if hh_t1 == 0 else hh_t1
            hh_t2 = 24 if hh_t2 == 0 else hh_t2
            if hh_t1 == hh_t2:
                return abs(mm_t1 -  mm_t2)

            time_diff1 = get_hours(hh_t1, hh_t2) * 60 + (mm_t2 - mm_t1)
            time_diff2 = get_hours(hh_t2, hh_t1) * 60 + (mm_t1 - mm_t2)


            return min(time_diff1, time_diff2)

        ans = float("inf")
        for t1 in all_times:
            for t2 in all_times:
                if t1 == t2 and  given_times[t1] > 1:
                    return 0

                elif t1 != t2 and given_times[t1] and  given_times[t2]:
                    ans = min(ans, diff(t1, t2))
         
        return ans
18800