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...
Leetcode - 12. Integer to Roman
DescriptionSeven different symbols represent Roman numerals with the following values: Symbol ValueI 1V 5X 10L 50C 100D 500M 1000Roman numerals are formed by appending the conversions of decimal place values from highest to lowest. Converting a decimal place value into a Roman numeral has the following rules: If the value does not start with 4 or 9, select the symbol of the maximal value that can be subtracted from the input, append that symbol to the result, subtract...
Network layer
Network layerThe network layer is responsible for delivering packets from the source host to the destination host across multiple networks. Its main functions include logical addressing, routing, forwarding, and error handling. It also supports different service models such as virtual circuit and datagram service. Network ServicesVirtual Circuit vs Datagram Service Virtual Circuit: A pre-established path between source and destination. It provides reliability and order but requires setup over...
Leetcode - 10. Regular Expression Matching
DescriptionGiven an input string s and a pattern p, implement regular expression matching with support for ‘.’ and ‘*’ where: ‘.’ Matches any single character.‘*’ Matches zero or more of the preceding element.The matching should cover the entire input string (not partial). Example 1:123Input: s = "aa", p = "a"Output: falseExplanation: "a" does not match the entire string "aa".Example 2:123Input: s = "aa", p = "a*"Output: trueExpl...






