Server Side Programming Articles

Page 1246 of 2109

Different methods to copy in C++ STL - std::copy(), copy_n(), copy_if(), copy_backwards()

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 561 Views

As the method name suggests copy() method is used to copy the data through various methods available in C++ STL. All the methods differ in functionalities and the parameters. These methods are available in header file. Let’s discuss each method and their functionalities.Copy(start_i1, end_i1, start_i2)This method is used to copy the data from one iterator to another iterator within specified range where both the start and end elements of an iterator are inclusive. It takes three types of arguments i.e. −Start_i1 − It will point to the initial element of the iterator, let’s say, i_1 from where the element ...

Read More

Find paths from corner cell to middle cell in maze in C++

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

Suppose we have a square maze filled with numbers; we have to find all paths from a corner cell to the middle cell. Here, we will proceed exactly n steps from a cell in 4 directions Up, Down, Right and Left where n is the value of the cell. Thus, we can move to cell [i+n, j] to [i-n, j], [i, j+n], and [i, j-n] from a cell [i, j] where n is value of cell [i, j].So, if the input is like344473463675662662334325472655123656334301434334321335354326443351375363624345451then the output will be(0, 0)→(0, 3)→(0, 7)→(6, 7)→(6, 3)→(3, 3)→(3, 4)→(5, 4)→(5, 2)→(1, 2)→(1, 7)→(7, 7)→(7, 1)→(2, ...

Read More

Find the largest area rectangular sub-matrix whose sum is equal to k in C++

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

Suppose we have a 2D matrix mat and a value K, we have to find the longest rectangular submatrix whose sum is same as K.So, if the input is like28-56-778-311-1443-43110And K = 9then the output will be Top-Left point is (1, 0) and Bottom-Right point is (3, 2).-77811-144-431To solve this, we will follow these steps −MAX := 100Define a function sum_k(), this will take one array arr, start, end, n, k, Define one mapsum := 0, maximum_length := 0for initialize i := 0, when i < n, update (increase i by 1), do −sum := sum + arr[i]if sum is ...

Read More

Count of alphabets having ASCII value less than and greater than k in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 397 Views

We are given a string of any length and the task is to calculate the count of alphabets having ASCII values less than or greater than or equals to the given integer value k.ASCII value for character A-Z are given belowABCDEFGHIJKLMNOPQRS65666768697071727374757677787980818283TUVWXYZ84858687888990ASCII value for characters a-z are given belowabcdefghijklmnopqrs979899100101102103104105106107108109110111112113114114tuvwxyz116117118119120121122Input − str = “TuTorials PoinT”, int k = 100Output −Count of alphabets having ASCII value less than k are − 6Count of alphabets having ASCII value equals or greater than k are − 9Explanation −We are given with k as 100 so we will check ASCII values of the characters in the ...

Read More

How to get the list of data sets available in base R or in a package in R?

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

There are many data sets available in base R and in different packages of R. The characteristics of these data sets are very different, for example, some data sets are time series data, some have only numerical columns, some have numerical as well as factor columns, some includes character columns with other type of columns. Therefore, it becomes helpful to everyone who want to learn the use of R programming. To get the list of available data sets in base R we can use data() but to get the list of data sets available in a package we first need ...

Read More

How to add a new column in an R data frame by combining two columns with a special character?

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

A data frame can have multiple types of column and some of them could be combined to make a single column based on their characteristics. For example, if a column has characters and the other has numbers then we might want to join them by separating with a special character to showcase them as an identity.ExampleConsider the below data frame −> ID Frequency set.seed(111) > ID Frequency df dfOutput   ID Frequency 1 A    78 2 B    84 3 C    83 4 D    47 5 E    25 6 F    59 7 G    69 8 ...

Read More

How to select columns of an R data frame that are not in a vector?

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

An R data frame can have so many columns and we might want to select them except a few. In this situation, it is better to extract columns by deselecting the columns that are not needed instead of selecting the columns that we need because the number of columns needed are more than the columns that are not needed. This can be done easily with the help of ! sign and single square brackets.ExampleConsider the below data frame −> Age Gender Salary ID Education Experience df dfOutput ID    Gender    Age     Salary    Experience    Education 1   ...

Read More

How to cut the elements of a numeric vector into multiple intervals in R?

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

A numeric vector may contain a large number of elements; therefore, we might want to convert that vector into a vector of intervals. For example, if we have 1 to 10 values in a vector then we might want to convert that vector into a vector of intervals such as (1, 5) for 1, 2, 3, 4, and 5 and (6, 10) for 6, 7, 8, 9, 10). This can be done by using cut function where we will use breaks argument to combine the vector elements in an interval.Examples> x1 x1Output[1] 1 2 3 4 5 6 7 8 ...

Read More

How to match two string vectors if the strings case is different in both the vectors in R?

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

We know that, R is a case sensitive programming language, hence matching strings of different case is not simple. For example, if a vector contains tutorialspoint and the other contains TUTORIALSPOINT then to check whether the strings match or not, we cannot use match function directly. To do this, we have to convert the lowercase string to uppercase or uppercase to lowercase with the match function.Examples> x1 x1Output[1] "z" "v" "r" "y" "z" "l" "v" "t" "f" "p" "p" "z" "e" "b" "a" "o" "m" "d" [19] "e" "l" "y" "y" "u" "u" "w" "b" "a" "j" "n" "v" "b" ...

Read More

How to find power of a matrix in R?

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

The power of a matrix in R cannot be found directly because there is not function in base R for that. Therefore, for this purpose we can use %^% of expm package. Firstly, we will install the expm package then load it and use %^%. For example, suppose we have a matrix called M and we want to find the M raise to the power 2 then it can be done as − M %^%2ExampleInstalling and Loading expm package −install.packages("expm") library(expm)ExampleM1

Read More
Showing 12451–12460 of 21,090 articles
Advertisements