Programming Articles

Page 1198 of 2547

Dudeney Numbers in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 749 Views

A mathematical number defined in number theory in a given number base is a natural number equal to the perfect cube of another natural number such that the digit sum of the first natural number is equal to the digit sum of the second number(wikipedia).The number was found by Henry Dudeney. Its mathematical formula is −Here, we are given an integer n. Our task is to check whether the given number n is a dudeney number or not. Let’s take an example to understand the problem, Input: N = 17592Output: NoExplanation:  The given number is not a dudney number.Solution Approach −The solution lies ...

Read More

Program to find number of operations required to remove palindromic sublists in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 326 Views

Suppose we have a list of numbers called nums. Now let us consider an operation where we delete some sublist which is a palindrome. We have to find the minimum number of operations required such that the list is empty.So, if the input is like nums = [6, 2, 4, 4, 2, 10, 6], then the output will be 2, as we can remove the sublist [2, 4, 4, 2] first then the list is like [6, 10, 6] this is also a palindrome, so remove it to make list empty.To solve this, we will follow these steps −Define an ...

Read More

How to create a plot in base R with tick marks but excluding axes lines?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 206 Views

To create a plot with tick marks but without axes lines, we first need to create the plot without axes and then add the tick marks. This can be done with the help of plot function and axis function in base R. The axis function will help us to decide where do we need the tick marks and the ticks.Example1> plot(1:10,axes=FALSE) > axis(1,c(1:10),col=NA,col.ticks=1)OutputExample2> x xOutput[1] 5 2 1 2 1Example> plot(x,axes=FALSE) > axis(1,c(1:5),col=NA,col.ticks=1)Output

Read More

Program to check we can replace characters to make a string to another string or not in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 246 Views

Suppose we have two lowercase strings s and t. Now consider an operation where we replace all occurrences of a character in s with another character. If we can perform this operation any number of times, we have to check whether s can be converted to t or not.So, if the input is like s = "eye" t = "pip", then the output will be True, as we can replace "e"s with "p"s then "y" by "i".To solve this, we will follow these steps −Define one map m1 and another map m2n := size of sfor initialize i := 0, ...

Read More

How to convert a matrix into a color matrix in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 1K+ Views

To convert a matrix into a color matrix, we can make use of image function. There are multiple ways for assigning the colors but the easiest one might be by defining the minimum and maximum value in the matrix. Also, we can do this by using the shades of a single color as shown in the example 3.Example1> M1 M1Output   [, 1] [, 2] [, 3] [, 4] [, 5] [1, ] 6    3    5    4    3 [2, ] 9    4    5    2    5 [3, ] 3    2    6 ...

Read More

How to plot the confidence interval of the regression model using ggplot2 with transparency in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 886 Views

To plot the confidence interval of the regression model, we can use geom_ribbon function of ggplot2 package but by default it will have dark grey color. It can become transparent with the help of alpha argument inside the same function, the alpha argument can be adjusted as per our requirement but the most recommended value by me is 0.2.ExampleConsider the below data frame −> x y df dfOutput x y 1 22.67102 29.37057 2 21.59415 29.54027 3 20.56817 28.27672 4 24.97228 31.38193 5 21.41651 31.86811 6 23.94699 ...

Read More

Element equal to the sum of all the remaining elements in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 252 Views

In this problem, we are given an array arr[] consisting of n positive values. Our task is to find the element equal to the sum of all the remaining elements of the array.Code Description: We need to find the element whose value is equal to the sum of all elements of the array except that element.Let’s take an example to understand the problem, Input: arr[] = { 5, 4, 17, 1, 7 }Output: 17Explanation −The sum of the rest of the element is (5 + 4 + 1 + 7 ) = 17, which is equal to the remaining element 17.Solution Approach −A simple ...

Read More

How to create a line for equal values of x and y in scatterplot in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 283 Views

To create a line for equal values of x and y in scatterplot, we can make use of segments function in base R but this can be done after creating the plot with the help of plot function. The segments function has four arguments, x0, y0, x1, and y1, we need to put the same value in x0 and y0 and the same value in x1 and y1 to draw the appropriate line as shown in the below examples.Example1> x xOutput[1] -1.14191974 1.11554154 -0.01255755 1.18841175 1.11300329 -0.69925814 [7] -0.88000117 0.67830803 -0.91237446 -1.14223973Example> y yOutput[1] -1.69229826 -0.70352587 0.38544874 0.14022473 0.15490539 -0.25938630 ...

Read More

Elements greater than the previous and next element in an Array in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 1K+ Views

In this problem, we are given an array arr[] of n positive integers. Our task is to create a program to find the elements greater than the previous and next element in an Array. Code Description: We need to find the elements of the array that satisfy the condition, the element is greater that the element at index 1 less than it and also is greater than the element at index 1 greater than it.Let’s take an example to understand the problem, Input: arr[] = {3, 2, 5, 7, 3, 4, 5}Output: 7Explanation −Element with index one less than the current element, 5.Element with ...

Read More

How to visualize a data frame that contains missing values in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 432 Views

If a data frame contains missing value then visualising it in base R is not easily possible but we can make use of visdat package for this purpose. The vis_dat function of visdat package helps to visualize any data frame even if it contains missing values. For example, if a data frame df contains missing value then it can be visualized as vis_dat(df).Example1Consider the below data frame −> x1 x2 x3 df1 df1Output x1 x2 x3 1 1 23 10 2 1 23 NA 3 NA NA 10 4 NA NA 10 5 1 24 NA 6 2 22 NA ...

Read More
Showing 11971–11980 of 25,466 articles
Advertisements