Minimum Absolute Difference in Python

Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements.  Return a list of pairs in ascending order(with respect to pairs), each pair [a, b] follows a, b are from arr a < b b – a equals to the minimum absolute difference of any two elements in arr Example 1: Input: arr = [4,2,1,3] … Read more Minimum Absolute Difference in Python


Minimum Time Visiting All Points in Python

On a plane, there are n points with integer coordinates points[i] = [xi, yi]. Your task is to find the minimum time in seconds to visit all points. You can move according to the next rules: In one second always you can either move vertically, horizontally by one unit or diagonally (it means to move one unit vertically … Read more Minimum Time Visiting All Points in Python


Search Suggestions System in Python

Given an array of strings products and a string searchWord. We want to design a system that suggests at most three product names from products after each character of searchWord is typed. Suggested products should have common prefix with the searchWord. If there are more than three products with a common prefix return the three lexicographically minimums products. Return list of lists of the suggested products after each … Read more Search Suggestions System in Python


Find Winner on a Tic Tac Toe Game in Python

Tic-tac-toe is played by two players A and B on a 3 x 3 grid. Here are the rules of Tic-Tac-Toe: Players take turns placing characters into empty squares (” “). The first player A always places “X” characters, while the second player B always places “O” characters. “X” and “O” characters are always placed into empty squares, never on filled ones. The game ends when there are 3 … Read more Find Winner on a Tic Tac Toe Game in Python


Number of Burgers with No Waste of Ingredients in Python

Given two integers tomatoSlices and cheeseSlices. The ingredients of different burgers are as follows: Jumbo Burger: 4 tomato slices and 1 cheese slice. Small Burger: 2 Tomato slices and 1 cheese slice. Return [total_jumbo, total_small] so that the number of remaining tomatoSlices equal to 0 and the number of remaining cheeseSlices equal to 0. If it is not possible … Read more Number of Burgers with No Waste of Ingredients in Python


Group the People Given the Group Size They Belong To in Python

Problem:  There are n people whose IDs go from 0 to n – 1 and each person belongs exactly to one group. Given the array groupSizes of length n telling the group size each person belongs to, return the groups there are and the people’s IDs each group includes. You can return any solution in any order and … Read more Group the People Given the Group Size They Belong To in Python


Find the Smallest Divisor Given a Threshold in Python

Problem:  Given an array of integers nums and an integer threshold, we will choose a positive integer divisor and divide all the array by it and sum the result of the division. Find the smallest divisor such that the result mentioned above is less than or equal to threshold. Each result of division is rounded to the nearest integer greater than … Read more Find the Smallest Divisor Given a Threshold in Python