# Tag: Python

• ## Longest Valid Parentheses – Leetcode Python

Given a string containing just the characters ‘(‘ and ‘)’, find the length of the longest valid (well-formed) parentheses substring. Examples Input: s = “(()” Output: 2 Explanation: The longest valid parentheses substring is “()”.

• ## Longest Palindromic Substring Solution – Python LeetCode

The goal is to create all palindromes of even and odd lengths while keeping track of the longest palindrome seen so far. To make a palindrome with an odd length, For lengthier palindromes, fix a centre and expand in both directions, i.e. fix I (index) as the centre and two indices as i1 = i+1 and i2 = i-1. If i1 and i2 are equal, reduce i2 and raise i1 to get the maximum length.

• ## 3sum Closest Leetcode Solution – Leetcode Python

Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.

• ## Next Permutation Leetcode – Python Solution

A permutation of an array of integers is an arrangement of its members into a sequence or linear order.

• ## Roman Numerals Decoder Codewars

Every symbol in Roman has a value associated with it. For example, X has a value of 10. Similarly, V has a value of 5. You need to add all the associated values, and you will get the number. For example, XXV where X=10 and V=5. Adding X+X+V = 10+10+5 = 25. But the Problem Arises when you have numbers like 4, 9, 40, etc. 9 is represented as IX in Roman, but if we apply the above technique. We will get I + X = 1 + 10 = 11. It is not Correct. When decoding Roman numerals, o

• ## 2D Array DS Hackerrank solution in Python

HackerRank has a coding Problem “2D Array DS Hackerrank solution in Python”. Today We are going to solve this problem. HackerRank Link of the Problem is HERE Question Given a 6×6 2D Array, arr: 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 […]

• ## How to Sort Numbers in Python without sort Function

Today we are going out to Sort Numbers in Python without sort Function. There is a similar Kata in Codewars to Sort only odd Numbers without sort Function in Python. The link of the similar Kata (sorting only odd numbers) is given HERE. Task: You will be given an array of numbers. You have to sort the numbers in ascending […]

• ## Python get domain name from URL – Python Solutions

Today we are going out to find the domain name out of the URL string through Python. There is a similar Kata in Codewars to extract the domain name from a URL through Python. Let’s say we have the URL string which is https://hecodesit.com/ What would be the domain name of this URL? The domain name will be hecodesit.  The URL […]