Note: The solution set must not contain duplicate quadruplets. Example: Given array nums = , and target = 0. A solution set is: , , ] Below are the steps to solve this problem. Step 1: Sort the array in ascending order. Step 2: Now we …

Input = , Output: , ] This problem can be solved in 2 ways: Time complexity O (n ^ 3). Time complexity O(n^2). We shall look into both of the solutions now: Solution 1: Iterative method: The solution here is simple, we take 3 pointers …

Given array has non repeating array and is sorted. Example 1: Input: Array = , key = 7, Output: , ] Example 2: Input: array = , key = 8, A solution set is: , , ] Here as there is no time …

Problem description: You are given non negative integers “i” represents x axis, and “a” represents y axis. “n” vertical lines are drawn, find two lines together x axis that forms a container. Find the container such that the container will hold the most water. I understand …

Given an input string (s) and a pattern (p), implement regular expression matching with support for ‘.’ and ‘*’. Note: '.' Matches any single character. '*' Matches zero or more of the preceding element. Example 1: Input: Pattern: a.b Valid Strings: acb - any character can be present …

A palindromic string will give the same string when reading reverse. Example: “aba” reverse is “aba” hence is a palindromic string. Input: ashdkabajjseiw Output: aba There are 3 approaches, in this tutorial, we shall discuss 2 methods Brute force approach. Time Complexity O(n ^ 3) Dynamic …

Problem Explanation: Given a string “prodevelopertutorial” and number of rows is 3. Write the string in a zigzag pattern. Example: Input: string = “prodevelopertutorial”. Number of rows 3 Output: array output should be: "peotrrdvlpruoiloeeta" Visualization of writing elements in zigzag fashion: Visualization of writing output in …

Problem Description: Given a positive integer array, find all the elements that have been repeated and display them. Example: Input: {1, 3, 2, 7, 5, 1, 3} Output: 1, 3 Solution: The solution is very simple. We traverse through the array and make the element in …