Uncategorized

Minimum Operations to Make Array Equal

You have an array arr of length n where arr[i] = (2 * i) + 1 for all valid values of i (i.e. 0 <= i < n). In one operation, you can select two indices x and y where 0 <= x, y < n and subtract 1 from arr[x] and add 1 to arr[y] (i.e. perform arr[x] -=1 and arr[y] += 1). The goal is to make all the elements of the array equal. It is guaranteed that all the elements of the …

Minimum Operations to Make Array Equal Read More »

Nth Catalan Number

Hi Geeks, in this article we going to see about what are Catalan numbers, how to find nth Catalan number, by using Catalan number how we can find the Unique Binary Search trees. Catalan Number Formation By using Catalan Numbers approach, here we will solve one problem from Leetcode – Unique Binary Search Trees. Given …

Nth Catalan Number Read More »

Longest Valid Parentheses

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

Longest Valid Parentheses Read More »

Reverse string in C#

Hi Geeks! This is a little pretty interesting question. How to reverse the string in C#? There are different ways available in C# to reverse the string. In this article, I’m going to discuss with you. Come on, Let’s examine that different ways. Input: “Developers Inspired” Output: “deripnsI srepoleveD” Our input and output is above😍 …

Reverse string in C# Read More »