less than 1 minute read

1491. Average Salary Excluding the Minimum and Maximum Salary (easy)

class Solution:
    def average(self, salary: List[int]) -> float:
        return (sum(salary) - min(salary) - max(salary)) / (len(salary) - 2)

1492. The kth Factor of n (medium)

class Solution:
    def kthFactor(self, n: int, k: int) -> int:
        if k == 1:
            return 1
        
        arr = []
        for i in range(1, n + 1):
            if n % i == 0:
                heappush(arr, i)

        if k > len(arr):
            return -1

        res = 0
        for i in range(k):
            res = heappop(arr)

        return res

371. Sum of Two Integers (medium)

class Solution:
    def getSum(self, a: int, b: int) -> int:
        while b:
            temp = a
            a = a ^ b
            b = (b & temp) << 1
        return a

2610. Convert an Array Into a 2D Array With Conditions (medium)

class Solution:
    def findMatrix(self, nums: List[int]) -> List[List[int]]:
        res = []
        counter = Counter(nums)
        while counter:
            temp = []
            for key in counter.keys():
                if counter[key] <= 0:
                    continue
                temp.append(key)
                counter[key] -= 1
            if not temp:
                break
            res.append(temp)
        
        return res