SSuryainsuryasun.hashnode.dev·Jan 3, 2024 · 1 min readTwo Sum II - Input Array Is Sorted Using Two Pointersvar twoSum = function (numbers, target) { let [start, end] = [0, numbers.length - 1]; while (start < end) { const currentSum = numbers[start] + numbers[end]; const isTarget = currentSum === target; if (isTarget) { ...00
SSuryainsuryasun.hashnode.dev·Jan 2, 2024 · 1 min readAnagramwhat is Anagram ? A word, phrase, or name formed by rearranging the letters of another, such as spar, formed from rasp. solution : Hash Map : const contacts = new Map(); contacts.set("Jessie", { phone: "213-555-1234", address: "123 N 1st Ave" }); con...00
SSuryainsuryasun.hashnode.dev·Dec 28, 2023 · 1 min read1.Contains DuplicateLeet code question Example 1: Input: nums = [1,2,3,1] Output: true Example 2: Input: nums = [1,2,3,4] Output: false Example 3: // code function containsDuplicate(nums){ // creating set using nums const isDuplicate=new Set(nums); ...00