Fix "Unable to locate package docker-compose-plugin" on Ubuntu
Install Docker Compose on UbuntuWhen trying to install Docker Compose with the command: 1sudo apt install docker-compose-plugin you might encounter the following error:1234Reading package lists... DoneBuilding dependency tree... DoneReading state information... DoneE: Unable to locate package docker-compose-pluginThis happens because the default Ubuntu repositories don’t include the latest Docker packages. To fix it, you need to enable the official Docker repository first. Solution Remove old...
Leetcode - 46. Permutations
DescriptionGiven an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. 1234Example 1:Input: nums = [1,2,3]Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] 1234Example 2:Input: nums = [0,1]Output: [[0,1],[1,0]] 1234Example 3:Input: nums = [1]Output: [[1]] 1234Constraints:1 <= nums.length <= 6-10 <= nums[i] <= 10 All the integers of nums are unique. Approach12345678910111213141516def permute(nums): res = [] b...
Leetcode - 53. Maximum Subarray
DescriptionGiven an integer array nums, find the subarray with the largest sum, and return its sum. 12345Example 1:Input: nums = [-2,1,-3,4,-1,2,1,-5,4]Output: 6Explanation: The subarray [4,-1,2,1] has the largest sum 6. 12345Example 2:Input: nums = [1]Output: 1Explanation: The subarray [1] has the largest sum 1. 12345Example 3:Input: nums = [5,4,-1,7,8]Output: 23Explanation: The subarray [5,4,-1,7,8] has the largest sum 23. 123Constraints:1 <= nums.length <= 105-104 <= nums[i] <=...
Leetcode - 70. Climb Stairs
DescriptionYou are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? 1234567Example 1:Input: n = 2Output: 2Explanation: There are two ways to climb to the top.1. 1 step + 1 step2. 2 steps 12345678Example 2:Input: n = 3Output: 3Explanation: There are three ways to climb to the top.1. 1 step + 1 step + 1 step2. 1 step + 2 steps3. 2 steps + 1 step 123Constraints:1 <= n <= 45 Approach123...
Leetcode - 18. 4Sum
DescriptionGiven an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that: 0 <= a, b, c, d < n a, b, c, and d are distinct. nums[a] + nums[b] + nums[c] + nums[d] == target You may return the answer in any order. 12345678Example 1:Input: nums = [1,0,-1,0,-2,2], target = 0Output: [[-2,-1,1,2],[-2,0,0,2],[-1,0,0,1]]Example 2:Input: nums = [2,2,2,2,2], target = 8Output: [[2,2,2,2]] 12345Constraints:1 <= nums.length <= ...
Leetcode - 17. Letter Combinations of a Phone Number
DescriptionGiven a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order. A mapping of digits to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. 1234Example 1:Input: digits = "23"Output: ["ad","ae","af","bd","be","bf","cd","ce","cf"] 1234Example 2:...
Leetcode - 16. 3Sum Closest
DescriptionGiven an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. 12345Example 1:Input: nums = [-1,2,1,-4], target = 1Output: 2Explanation: The sum that is closest to the target is 2. (-1 + 2 + 1 = 2). 12345Example 2:Input: nums = [0,0,0], target = 1Output: 0Explanation: The sum that is closest to the target is 0. (0 ...
Leetcode - 15. 3Sum
DescriptionGiven an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set must not contain duplicate triplets. 12345678910Example 1:Input: nums = [-1,0,1,2,-1,-4]Output: [[-1,-1,2],[-1,0,1]]Explanation: nums[0] + nums[1] + nums[2] = (-1) + 0 + 1 = 0.nums[1] + nums[2] + nums[4] = 0 + 1 + (-1) = 0.nums[0] + nums[3] + nums[4] = (-1) + 2 + (-1) = 0.The distinct triplets are [...
Leetcode - 14. Longest Common Prefix
DescriptionWrite a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string “”. 1234Example 1:Input: strs = ["flower","flow","flight"]Output: "fl" 12345Example 2:Input: strs = ["dog","racecar","car"]Output: ""Explanation: There is no common prefix among the input strings. 12345Constraints:1 <= strs.length <= 2000 <= strs[i].length ...
Leetcode - 13. Roman to Integer
DescriptionRoman numerals are represented by seven different symbols: I, V, X, L, C, D and M.12345678Symbol ValueI 1V 5X 10L 50C 100D 500M 1000For example, 2 is written as II in Roman numeral, just two ones added together. 12 is written as XII, which is simply X + II. The number 27 is written as XXVII, which is XX + V + II. Roman numerals are usually written largest to smallest from left to right. Howeve...







