LeetCode 15 3Sum Explained Like a Production Engineer (Java, C++, Python)
The 3Sum problem is one of the most popular problems on LeetCode.It looks simple, but many developers struggle with it because of duplicate handling…
// category archive
106 articles
The 3Sum problem is one of the most popular problems on LeetCode.It looks simple, but many developers struggle with it because of duplicate handling…
Given a string s, return the longest palindromic substring in s. A string is called a palindrome string if the reverse of that string is the same as…
Find the length of the longest substring without repeated characters given a string s. Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The…
You are given two non-empty linked lists that each represent a non-negative integer. The digits are kept in reverse order, with each node containing…
Provide the median of the two sorted arrays given two sorted arrays of sizes m and n, respectively. The entire complexity of the run…
The Two Sum problem is one of the most popular beginner-friendly questions on LeetCode.It is frequently asked in coding interviews and helps you understand…
Given the root of a binary tree, return the level order traversal of its nodes’ values. (i.e., from left to right, level by level). Example 1: Input:…
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…
Given the root of a binary tree, determine if it is a valid binary search tree (BST). A valid BST is defined as follows: Example 1: Input: root =…
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 =…
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 =…
Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive. There is only one repeated number in nums, return this repeated number. You must solve…
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:…
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.…
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…
Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty…