JavaScript

Leet Code: Longest Substring Without Repeating Characters Java | JavaScript | CPP | Python Solution

leetcode question solution

Find the length of the longest substring without repeated characters given a string s. Example 1: Input: s = “abcabcbb” Output: 3 Explanation: The answer is “abc”, with the length of 3. Example 2: Input: s = “bbbbb” Output: 1 Explanation: The answer is “b”, with the length of 1. Example 3: Input: s = […]

Leet Code: Longest Substring Without Repeating Characters Java | JavaScript | CPP | Python Solution Read More »

leet code 1. Two sum (easy)

Leetcode 1. Two Sum

Leet Code 1. Two Sum : Hey there, coding enthusiasts! Welcome back to another exciting coding session. Today’s problem is a treat—literally! We’re going to solve the “two sum ” or “Leet Code .1‘ Time Complexity: C++: 1. Brute Force Approach: LeetCode 15 : Three (3) Sum Notice: This approach has a time complexity of

leet code 1. Two sum (easy) Read More »

Leet Code :Linked List Cycle II Java || Python || C++ solution

leetcode question solution

Given the head of a linked list, return the node where the cycle begins. If there is no cycle, return null. There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of the node that tail’s next pointer is connected

Leet Code :Linked List Cycle II Java || Python || C++ solution Read More »

Leet Code :Running Sum of 1d Array Solution C++ || Python || Java

leetcode question solution

Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]). Return the running sum of nums. Example 1: Input: nums = [1,2,3,4] Output: [1,3,6,10] Explanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4]. Example 2: Input: nums = [1,1,1,1,1] Output: [1,2,3,4,5] Explanation: Running sum is obtained as follows: [1, 1+1,

Leet Code :Running Sum of 1d Array Solution C++ || Python || Java Read More »

leet code median of two sorted array Java ,C++ ,C, JS solution

leetcode question solution

Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Example 1: Input: nums1 = [1,3], nums2 = [2] Output: 2.00000 Explanation: merged array = [1,2,3] and median is 2. Example 2: Input: nums1 = [1,2], nums2 = [3,4] Output: 2.50000 Explanation: merged array = [1,2,3,4]

leet code median of two sorted array Java ,C++ ,C, JS solution Read More »

Leet Code: Rotate Array C++ Python || JavaScript || Java solution:

leetcode question solution

Given an array, rotate the array to the right by k steps, where k is non-negative. Example 1: Input: nums = [1,2,3,4,5,6,7], k = 3 Output: [5,6,7,1,2,3,4] Explanation: rotate 1 steps to the right: [7,1,2,3,4,5,6] rotate 2 steps to the right: [6,7,1,2,3,4,5] rotate 3 steps to the right: [5,6,7,1,2,3,4] Example 2: Input: nums = [-1,-100,3,99], k = 2 Output:

Leet Code: Rotate Array C++ Python || JavaScript || Java solution: Read More »

Leet Code : Merge k Sorted Lists C++ , Java , Python solution

leetcode question solution

You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. Merge all the linked-lists into one sorted linked-list and return it. Example 1: Input: lists = [[1,4,5],[1,3,4],[2,6]] Output: [1,1,2,3,4,4,5,6] Explanation: The linked-lists are: [ 1->4->5, 1->3->4, 2->6 ] merging them into one sorted list: 1->1->2->3->4->4->5->6 Example 2: Input: lists = [] Output:

Leet Code : Merge k Sorted Lists C++ , Java , Python solution Read More »

Leet Code : longest common prefix string C++ ,java , Python Solution

leetcode question solution

Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string “”. Example 1: Input: strs = [“flower”,”flow”,”flight”] Output: “fl” Example 2: Input: strs = [“dog”,”racecar”,”car”] Output: “” Explanation: There is no common prefix among the input strings. Java Solution C++ solution

Leet Code : longest common prefix string C++ ,java , Python Solution Read More »