Nizamuddin Siddiqui has Published 2307 Articles

How to find all the unique quadruplets that is close to zero using C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 17-Aug-2021 07:38:42

160 Views

The easy approach is that we could create four nested loops and check one by one that the sum of all the four elements is zero or not. If the sum of the four elements is zero then print elements.Time Complexity − O(n4)Space Complexity − O(1)We could use an unordered ... Read More

How to find the unique triplet that is close to the given target using C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 17-Aug-2021 07:29:39

148 Views

Two Pointers pattern and is similar to Triplet Sum to Zero. We can follow a similar approach to iterate through the array, taking one number at a time. At every step, we will save the difference between the triplet and the target number, and at each step we will compare ... Read More

How to find the longest distance to a character in a given string using C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 17-Aug-2021 07:16:51

178 Views

Create 2 different arrays leftDis and rightDis. The leftDis will store the value when moved from left direction. The rightDis will store the shortest value when moved from right. Whenever the character is met add the position of the character to the array. In the last step calculate the maximum ... Read More

How to find the shortest distance to a character in a given string using C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 17-Aug-2021 07:07:19

295 Views

Create 2 different arrays leftDis and rightDis. The leftDis will store the value when moved from left direction. The rightDis will store the shortest value when moved from right. Whenever the character is met add the position of the character to the array. In the last step calculate the minimum ... Read More

How to find all unique triplets that adds up to sum Zero using C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 17-Aug-2021 07:03:40

215 Views

The easy approach is that we could create three nested loops and check one by one that the sum of all the three elements is zero or not. If the sum of the three elements is zero then print elements.Time Complexity − O(n3)Space Complexity − O(1)We could use an unordered ... Read More

How to search in a row wise increased matrix using C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 17-Aug-2021 06:49:57

129 Views

The primitive solution for this problem is to scan all elements stored in the input matrix to search for the given key. This linear search approach costs O(MN) time if the size of the matrix is MxN.The matrix needs to be scanned from the top right, if the search element ... Read More

How to search in a row wise and column wise increased matrix using C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 17-Aug-2021 06:46:07

158 Views

The primitive solution for this problem is to scan all elements stored in the input matrix to search for the given key. This linear search approach costs O(MN) time if the size of the matrix is MxN.The matrix can be viewed as a sorted one-dimensional array. If all rows in ... Read More

How to check whether the given matrix is a Toeplitz matrix using C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 17-Aug-2021 06:39:33

483 Views

A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same elements.Example 1[[1, 2, 3, 4], [5, 1, 2, 3], [9, 5, 1, 2]]Output −trueIn the above grid, the diagonals are −"[9]", "[5, 5]", "[1, 1, 1]", "[2, 2, 2]", "[3, 3]", "[4]".In each diagonal all elements ... Read More

How to create scatterplot using ggplot2 without grey background in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 14-Aug-2021 08:55:48

171 Views

To create scatterplot using ggplot2 without grey background in R, we can follow the below steps −First of all, create a data frame.Then, create the scatterplot using geom_point function of ggplot2 package.After that, add theme_minimal() function to the ggplot function.Create the data frameLet's create a data frame as shown below ... Read More

How to display NA frequency for a ggplot2 graph using color brewer in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 14-Aug-2021 08:55:14

816 Views

To display NA frequency for a ggplot2 graph using color brewer in R, we can follow the below steps −First of all, create a data frame.Then, create the chart with default colors.After that, use scale_colour_brewer function to create the bar chart and set the color of NA values bar with ... Read More

Advertisements