JavaScript

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 : Reverse Nodes in k-Group Java, Python ,C++ JavaScript Solution

leetcode question solution

Given the head of a linked list, reverse the nodes of the list k at a time, and return the modified list. k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes, in the end, should remain as it is. You

Leet Code : Reverse Nodes in k-Group Java, Python ,C++ JavaScript 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 »