Programming Articles - Page 2122 of 3363

Balanced expressions such that given positions have opening brackets in C++?

Arnab Chakraborty
Updated on 29-Jan-2020 10:57:50

240 Views

In case of a given integer m and an array of positions ‘position[]’ (1

Autorun a Python script on windows startup?

Arnab Chakraborty
Updated on 29-Jan-2020 10:43:54

1K+ Views

Appending a Python script to windows start-up basically indicates the python script will run as the windows boots up. This can be accomplished by two step processes -Step #1: Appending or Adding script to windows Startup folderAfter booting up of the windows, it executes (equivalent to double-clicking) all the application present in its startup folder or directory.AddressC:\Users\current_user\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\By default, the AppData directory or folder under the current_user is hidden that enable hidden files to get it and paste the shortcut of the script in the given address or the script itself. Besides this the .PY files default must be set ... Read More

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

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

257 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

278 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

213 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

232 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

241 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

436 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

97 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

Advertisements