<prompt> Kutokana na idadi integer safu, kurudi tatu tofauti idadi kubwa katika safu hii. Kama tatu kiwango cha juu haipo, kurudi idadi kubwa.  <response>: Here is the Python code to solve the problem using a set and sorting:def thirdMaxnums: unique_nums sortedsetnums, reverseTrue return unique_nums2 if lenunique_nums 3 else unique_nums0Explanation: We create a set from the input array nums to get rid of duplicates. Then, we sort the resulting set in descending order. If the set has at least 3 distinct elements, we return the third element. Otherwise, we return the maximum element, which is the first element in the sorted set. 