Found 26504 Articles for Server Side Programming

Arrange consonants and vowels nodes in a linked list in C++?

Nishu Kumari
Updated on 06-Aug-2025 11:10:56

224 Views

A singly linked list is a fundamental data structure that consists of nodes,  where each node contains a data field and a reference to the next node in the linked list. The next of the last node is null, indicating the end of the list. The given task is to rearrange the linked list in such a way that all the vowel nodes precede the consonants while maintaining the order of their arrival. Scenario Input: a -> b-> c -> d-> e-> f-> g-> h-> i Output: a-> e-> i-> b-> c-> d-> f-> g-> h To solve this problem, we ... Read More

Arrange a binary string to get maximum value within a range of indices C/C++?

Arnab Chakraborty
Updated on 29-Jan-2020 08:14:40

255 Views

In case of a given string consisting of only 0’s and 1’s, we are given M non-intersecting ranges A, B( A

Are array members deeply copied in C++?

Aman Kumar
Updated on 24-Jul-2025 15:49:59

1K+ Views

In C++, an array member is simply the individual elements stored within an array. What is Deep Copy? A deep copy creates a new object and allocates separate memory for the dynamically allocated resources; it copies all the data members of the original object into the new object. So that the new object is completely independent of the original. When a class has a pointer to dynamic memory, the default copy constructor and assignment operator will perform a shallow copy, which is a copy of the pointer rather than the data. So, must define our own ... Read More

Angle between a chord and a tangent when angle in the alternate segment is given in C++?

Manisha Chand
Updated on 08-Aug-2025 11:17:45

166 Views

In this problem, we are given a circle whose chord and tangent meet at a particular point. The angle in the alternate segment of a circle is given. We need to find the angle between the chord and the tangent. According to the Alternate Segment Theorem the angle between a chord and a tangent is equal to the angle in the alternate segment of the circle. Chord and Tangent The chord of a circle can be defined as the line segment joining any two points on ... Read More

An in-place algorithm for String Transformation in C++

Nishu Kumari
Updated on 06-Aug-2025 16:18:30

199 Views

We are given a string and need to move all characters at even positions to the end of the string while maintaining the original order of both even-positioned and odd-positioned characters. The transformation should be done in-place (without using extra space) and in O(n) time. Let's look at a few example scenarios to understand the problem clearly. Scenario 1 Input: T1u2t0o6r2i0a0l4s Output: Tutorials12062014 Explanation: Odd-positioned characters are T u t o r i a l s. Even-positioned characters are 1 2 0 6 2 0 1 4. We place the even-positioned characters at the end while keeping their ... Read More

An application on Bertrandís ballot theorem in C/C++

Arnab Chakraborty
Updated on 29-Jan-2020 07:51:43

214 Views

In Bertrand's original paper, he explains a proof depended on a general formula for the number of favourable sequences implementing a recursion relation.ExampleLet there are 5 voters, of whom 3 vote for candidate A and 2 vote for candidate B (so p = 3 and q = 2). Ten possibilities are exist for the order of the votes cast −AAABBAABABABAABBAAABAABBAABABABAABAABBAABABAABBAAAFor the order AABAB, the tally of the votes as the election progresses is given below −CandidateAABABA12233B00112For each column the tally for A is always greater than the tally for B so the A is always strictly ahead of B. For ... Read More

Converting Decimal Number lying between 1 to 3999 to Roman Numerals in C++

Ayush Gupta
Updated on 29-Jan-2020 07:45:23

415 Views

In this tutorial, we will be discussing a program to convert decimal number lying between 1 to 3999 to roman numerals.For this we will be provided with a random integer. Our task is to convert the given number into its roman numeral equivalent.Example Live Demo#include using namespace std; //converting decimal to roman numeral int printRoman(int number){    int num[] = {1,4,5,9,10,40,50,90,100,400,500,900,1000};    string sym[] =    {"I","IV","V","IX","X","XL","L","XC","C","CD","D","CM","M"};    int i=12;    while(number>0){       int div = number/num[i];       number = number%num[i];       while(div--){          cout

Convert to number with digits as 3 and 8 only in C++

Ayush Gupta
Updated on 29-Jan-2020 07:44:12

82 Views

In this tutorial, we will be discussing a program to convert a number to have digits as 3 and 8 only.For this we will be provided with a random number. Our task is to convert its digits to be only 3 and 8 by either adding/subtracting 1 from the number or converting digits of the number to any desired digit.Example Live Demo#include using namespace std; //calculating minimum operations required int cal_min(long long int num){    //calculating remainder and operations    int rem;    int count = 0;    while (num) {       rem = num % 10;   ... Read More

Convert to Strictly increasing integer array with minimum changes in C++

Ayush Gupta
Updated on 29-Jan-2020 07:43:14

193 Views

In this tutorial, we will be discussing a program to convert to strictly increasing integer array with minimum changes.For this we will be provided with an array. Our task is to change the elements of the array to be in strictly increasing order by minimum number of changes in the elements.Example Live Demo#include using namespace std; //calculating number of changes required int remove_min(int arr[], int n){    int LIS[n], len = 0;    for (int i = 0; i < n; i++)    LIS[i] = 1;    for (int i = 1; i < n; i++) {       ... Read More

Converting one string to other using append and delete last operations in C++

Ayush Gupta
Updated on 29-Jan-2020 07:49:47

139 Views

In this tutorial, we will be discussing a program to convert one string to other using append and delete last operations.For this we will be provided with two strings. Our task is to calculate whether the first string can be converted into the second one by performing k operations of append and delete last element.Example#include using namespace std; //checking if conversion between strings is possible bool if_convert(string str1, string str2, int k){    if ((str1.length() + str2.length()) < k)    return true;    //finding common length of both string    int commonLength = 0;    for (int i = ... Read More

Advertisements