Thanga Ganapathyganapathy.hashnode.dev·Apr 22, 2024How to Compare Same Contents but Different Ordered Arrays in JavaScript?Welcome, One common challenge developers face is comparing arrays—specifically, determining if two arrays contain the same contents, regardless of the order of those contents. This task might seem straightforward at first glance, but it quickly delve...DiscussJavaScript
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, 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, 2024Longest Strictly Increasing or Strictly Decreasing SubarrayYou are given an array of integers nums. Return the length of the longest subarray ofnums which is either strictly increasing or strictly decreasing. LeetCode Problem - 3105 class Solution { public int longestMonotonicSubarray(int[] nums) { ...DiscussJava Solutionarray
Gulshan Kumarperfinsights.hashnode.dev·Apr 21, 2024Contains Duplicate IIGiven an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k. LeetCode Problem - 219 import java.util.*; class Solution { public boolean contain...DiscussJava SolutionJava
Gulshan Kumarperfinsights.hashnode.dev·Apr 21, 2024Remove K DigitsGiven string num representing a non-negative integer num, and an integer k, return the smallest possible integer after removing k digits from num. LeetCode Problem - 402 import java.util.*; class Solution { public String removeKdigits(String num...DiscussJava SolutionJava
Romman Sabbirrommansabbir.com·Apr 20, 2024Kotlin's Collections in a Nutshell[Background Image by JOHN TOWNER] Kotlin, known for its conciseness, expressiveness, and interoperability with Java, provides powerful tools for working with collections. What is Collections in Kotlin? The Collections class in Kotlin is like a toolbo...Discuss·55 readsKotlinKotlin
Suraj Chaturvedimernsuraj.hashnode.dev·Apr 16, 2024"Continuing the MERN Journey: Mastering JavaScript Arrays for Efficient Data Handling!"Arrays are data structures used to store multiple pieces of similar or diverse data under a single variable name in programming. They provide a convenient way to organize and manage data, whether it's a list of numbers, strings, or a mix of different...Discussarray