Agatha ChituwaforCodebyAgathacodebyagatha.hashnode.dev·Apr 23, 2024LeetCode Problem 2635 Apply Transform Over Each Element in Array — LeetCode: 30 Days of JavaScriptI’ve been going through the 30 Days of Javascript in LeetCode. Right now, I’m on 2635. Apply Transform Over Each Element in Array. Problem: Given an integer array arr and a mapping function fn, return a new array with a transformation applied to each...Discuss·11 likes·26 readsJavaScript
Agatha ChituwaforCodebyAgathacodebyagatha.hashnode.dev·Apr 23, 2024LeetCode Problem 2665 Counter II — LeetCode: 30 Days of JavaScriptSolving Leetcode 30 Days of JavaScript study plan problems Problem: Write a function createCounter. It should accept an initial integer init. It should return an object with three functions. The three functions are: increment() increases the current...Discuss·1 likeJavaScript
Gulshan Kumarperfinsights.hashnode.dev·Apr 21, 2024Count the Number of Special Characters IYou are given a string word. A letter is called special if it appears both in lowercase and uppercase in word. Return the number of special letters in word. LeetCode Problem - 3120 import java.util.*; class Solution { // Function to count the nu...DiscussJava SolutionJava
Gulshan Kumarperfinsights.hashnode.dev·Apr 21, 2024Find Missing and Repeated ValuesYou are given a 0-indexed 2D integer matrix grid of size n * n with values in the range [1, n<sup>2</sup>]. Each integer appears exactly once except a which appears twice and b which is missing. The task is to find the repeating and missing numbers a...DiscussJava Solutionarray
Gulshan Kumarperfinsights.hashnode.dev·Apr 21, 2024Find Common Elements Between Two ArraysYou are given two 0-indexed integer arrays nums1 and nums2 of sizes n and m, respectively. Consider calculating the following values: The number of indices i such that 0 <= i < n and nums1[i] occurs at least once in nums2. The number of indices i s...DiscussJava Solutionarray
Gulshan Kumarperfinsights.hashnode.dev·Apr 21, 2024Jewels and StonesYou're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to know how many of the stones you have are also jewels. Letters...DiscussJava Solutionhashmap
Gulshan Kumarperfinsights.hashnode.dev·Apr 21, 2024Count Number of Pairs With Absolute Difference KGiven an integer array nums and an integer k, return the number of pairs (i, j) where i < j such that |nums[i] - nums[j]| == k. The value of |x| is defined as: x if x >= 0. -x if x < 0. LeetCode Problem - 2006 class Solution { // Function to ...DiscussJava Solutionarray
Gulshan Kumarperfinsights.hashnode.dev·Apr 21, 2024Truncate SentenceA sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each of the words consists of only uppercase and lowercase English letters (no punctuation). For example, "Hello World", "HELLO", and "hello world...DiscussJava SolutionJava
Gulshan Kumarperfinsights.hashnode.dev·Apr 21, 2024Keep Multiplying Found Values by TwoYou are given an array of integers nums. You are also given an integer original which is the first number that needs to be searched for in nums. You then do the following steps: If original is found in nums, multiply it by two (i.e., set original = ...DiscussJava Solutionleetcode
Gulshan Kumarperfinsights.hashnode.dev·Apr 21, 2024Sum of Left LeavesGiven the root of a binary tree, return the sum of all left leaves. A leaf is a node with no children. A left leaf is a leaf that is the left child of another node. LeetCode Problem - 404 /** * Definition for a binary tree node. * public class Tree...DiscussJava SolutionJava