Tapan Rachchhtapanrachchh.hashnode.dev·Jun 18, 2024826. Most Profit Assigning Workclass Solution: def maxProfitAssignment(self, difficulty: List[int], profit: List[int], worker: List[int]) -> int: N = len(profit) data = [[profit[i], difficulty[i]] for i in range(N)] data = sorted(data, key = lambda x: (...DiscussPython

Tapan Rachchhtapanrachchh.hashnode.dev·Jun 14, 2024945. Minimum Increment to Make Array Uniqueclass Solution: def minIncrementForUnique(self, nums: List[int]) -> int: nums.sort() ans = 0 for i in range(len(nums) - 1): if nums[i] >= nums[i + 1]: ans += 1 + (nums[i] - nums[i + 1]) ...DiscussPython

Alex Mercedalexmerced.hashnode.dev·Jun 13, 2024Introduction to Sorting Algorithms in JavaScriptMy Video and Written Content New Developer Docs Introduction to Sorting Algorithms in JavaScript 1. Introduction Sorting algorithms are fundamental to computer science and programming. They are essential tools for organizing data in a meaningful ord...DiscussJavaScript

Tapan Rachchhtapanrachchh.hashnode.dev·Jun 13, 20242037. Minimum Number of Moves to Seat Everyoneclass Solution: def minMovesToSeat(self, seats: List[int], students: List[int]) -> int: seats.sort() students.sort() diff = 0 for i in range(len(seats)): diff += abs(seats[i] - students[i]) re...DiscussPython

Tapan Rachchhtapanrachchh.hashnode.dev·Jun 12, 202475. Sort Colorsclass Solution: def sortColors(self, nums: List[int]) -> None: c = Counter(nums) count = [] for e in range(3): count += [e] * c[e] for i in range(len(nums)): nums[i] = count[i]Discussleetcode

Tapan Rachchhtapanrachchh.hashnode.dev·Jun 10, 20241051. Height Checkerclass Solution: def heightChecker(self, heights: List[int]) -> int: minVal = float('inf') maxVal = 0 freq = defaultdict(int) for height in heights: freq[height] += 1 minVal = min(minVal, he...Discusscounter-sort

Gulshan Kumarperfinsights.hashnode.dev·Jun 9, 2024Count Days Without MeetingsYou are given a positive integer days representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array meetings of size n where, meetings[i] = [start_i, end_i] represents the starting and en...DiscussJava Solutionarray

Mahbub Alam Masumblog.masum.dev·Jun 2, 2024Insertion Sort AlgorithmInsertion Sort is a straightforward and efficient comparison-based sorting algorithm. The algorithm works similarly to how you might sort playing cards in your hands. It builds the sorted array one item at a time by taking each element from the unsor...DiscussSorting AlgorithmsDSA

Mahbub Alam Masumblog.masum.dev·Jun 1, 2024Bubble Sort AlgorithmBubble Sort is a simple comparison-based sorting algorithm. It repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. The process is repeated until the list is sorted. This algorithm gets its name...DiscussSorting Algorithmsoptimized bubble sort

Mahbub Alam Masumblog.masum.dev·Jun 1, 2024Selection Sort AlgorithmSelection Sort is a simple and intuitive sorting algorithm. It divides the input list into two parts: a sorted sublist of items which is built up from left to right at the front (left) of the list and a sublist of the remaining unsorted items. The al...Discuss·52 readsSorting AlgorithmsDSA