
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7197 Articles for C++

204 Views
In this problem, we are given an array arr[] in which each element represents a pile of boxes (each of unit height). Our task is to find the number of boxes to be removed.The person is standing at index 0 of the array at the height of the pile of boxes and he needs to move to the end of the array. The condition to move from one pile to the next is by jumping to the next.Jump is possible only when the next pile is at the same height or is at height less than it. If the height ... Read More

194 Views
In this problem, we are given an integer value N.Our task is to Find the nth term of the series −9, 45, 243, 1377, 8019, …Let’s take an example to understand the problem,Input : N = 4 Output : 1377Solution ApproachA simple solution to find the problem is by finding the Nth term using observation technique. On observing the series, we can formulate as follow −(11 + 21)*31 + (12 + 22)*32 + (13 + 23)*33 … + (1n + 2n)*3nExampleProgram to illustrate the working of our solution#include #include using namespace std; long findNthTermSeries(int n){ return ( ( (pow(1, n) + pow(2, n)) )*pow(3, n) ); } int main(){ int n = 4; cout

352 Views
In this problem, we are given an integer value N. Our task is to find the nth term of the series −0, 8, 64, 216, 512, 1000, 1728, 2744…Let’s take an example to understand the problem, Input: N = 6 Output: 1000Solution ApproachTo find the Nth term of the series, we need to closely observe the series. The series is the cube of even numbers, where the first term is 0.So, the series can be decoded as −[0]3, [2]3, [4]3, [6]3, [8]3, [10]3…For ith term, T1 = [0]3 = [2*(1-1)]3T2 = [2]3 = [2*(2-1)]3T3 = [4]3 = [2*(3-1)]3T4 = [6]3 ... Read More

466 Views
In this problem, we are given an integer value N. Our task is to Find the nth term of the given series −0, 0, 2, 1, 4, 2, 6, 3, 8, 4, 10, 5, 12, 6, 14, 7, 16, 8, 18, 9, 20, 10… Let’s take an example to understand the problem, Input − N = 6 Output − 2Solution ApproachTo find the Nth term of the series, we need to closely observe the series. It is the mixture of two series and odd and even terms of the series. Let’s see each of them, At even positions −T(2) = 0T(4) ... Read More

3K+ Views
In this article, we need to reverse the links with the help of a singly linked list. Our task is to create a function that is capable of reversing the given singly linked list. For exampleInput: Following Linked list : 1->2->3->4->NULL Output: After processing of our function: 4->3->2->1->NULLApproach to find The SolutionThere are different approaches to reverse a linked list. Generally, a simple approach comes to our mind to traverse the list and reverse it while going through it.Simple ApproachWe will go through the linked list in this approach and try to reverse it while going through it.Example#include using ... Read More

283 Views
In this article, we deal with a singly linked list, and the task is to reverse the list in groups of k. For example −Input: 1->2->3->4->5->6->7->8->NULL, K = 3 Output: 3->2->1->6->5->4->8->7->NULL Input: 1->2->3->4->5->6->7->8->NULL, K = 5 Output: 5->4->3->2->1->8For this problem, one approach that comes to mind is trailing the list and reversing the list when our sublist’s size reaches k and continues.Approach to find The SolutionIn this approach, we will generally traverse through the list and keep a counter to count the number of elements in our sub-list. When the counter reaches the count of k, we reverse that ... Read More

397 Views
In this problem, we are given a pointer to the head of a linked list and an integer k. In groups of size k, we need to reverse the linked list. For example −Input : 1 2 3 4 5 (doubly linked list), k = 3 Output : 3 2 1 5 4Approach to find The SolutionIn this problem, we are going to make a recursive algorithm to solve this problem. In this approach, we are going to use recursion and solve the problem using that.Example#include using namespace std; struct Node ... Read More

740 Views
In this article we have a doubly linked list, and we will explain different approaches to reverse a doubly linked list in C++. For example −Input : {1, 2, 3, 4} Output : {4, 3, 2, 1}There is generally one approach that comes to mind, but we will use two approaches − The normal and unorthodox approach.Normal ApproachIn this approach, we will go through the list, and as we go through it, we reverse it.Example#include using namespace std; class Node { public: int data; Node *next; Node *prev; }; void reverse(Node **head_ref) ... Read More

765 Views
In this article, we will understand the Reversal algorithm to rotate a given array by k-elements to the right, for example −Input : arr[ ] = { 4, 6, 2, 6, 43, 7, 3, 7 }, k = 4 Output : { 43, 7, 3, 7, 4, 6, 2, 6 } Explanation : Rotating each element of array by 4-element to the right gives { 43, 7, 3, 7, 4, 6, 2, 6 }. Input : arr[ ] = { 8, 5, 8, 2, 1, 4, 9, 3 }, k = 3 Output : { 4, 9, 3, 8, ... Read More

298 Views
In the given problem, we are given an array, and we are required to rotate the array by d elements using a reversal algorithm, for example −Input : arr[] = [1, 2, 3, 4, 5, 6, 7], d = 2 Output : arr[] = [3, 4, 5, 6, 7, 1, 2] Explanation : As you can see we have to rotate this array by d = 2 but our main task is to achieve this by using a reversal technique.We make some calculations for the rotation of the array by reversal technique, and we conclude that −First, we reverse the ... Read More