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 …

Example: Input: {4, 2, 5, 8, 21, 34, 10} key = 24 Output: Pair found (34, 10) This problem can be solved in 2 ways. Solution 1: Brute force method. Explanation: Step 1: Take 2 loops, outer loop and an inner loop. Step 2: The element …

Problem Statement: Given an unsorted array, list all the pairs with the least difference. Example: Input: {5, 4, 3, 2, 1} Output: {1, 2}, {2, 3}, {3, 4}, {4, 5}. Solution Explanation: Step 1: Sort the array. Step 2: Find the least difference. Step 3: Find …

Problem Explanation: Given an unsorted array, the output should be the minimum difference between the elements and the elements itself. Example: Input: {6, 10, 5, 42, 43, 1, 2} output: The minimum difference between is 1 the elements are 1 and 2. This can be solved …

Example: Array: {5, 6, 7, 6, 5, 4, 3, 4, 5, 6} Key: 4 Output: The element 4 is found at the index 6. Explanation: We can solve this approach by traveling the matrix element one by one and searching for the element. But we can …