Server Side Programming Articles - Page 1814 of 2650

XOR of numbers that appeared even number of times in given Range in C++

sudhir sharma
Updated on 20-Apr-2020 11:48:19

174 Views

In this problem, we are given an array of n elements and there are some queries which are range from a start point to endpoint in the array. Our task is two finds the XOR of elements that appeared even a number of times in the range.Let’s take an example to understand the problem, Input −array = {1, 2, 3, 1, 1, 2, 2, 3} querries = 2 R = 4 L = 2, R = 5 L = 2, R = 7Output −0 1 0The solution to this problem is quite easy, we will find the sum of XOR ... Read More

XOR of the path between any two nodes in a Binary Tree in C++

sudhir sharma
Updated on 20-Apr-2020 11:45:21

332 Views

In this problem, we are given a binary tree and two nodes of the binary tree. Our task is to print the XOR of all nodes that come in the path between the two nodes.Let’s take an example to understand the problem, We need to find the xor of all nodes between 2 and 3.The path from 2 to 3, 2 → 6 → 1 → 3.We will find 2^3^1^3.Output −To solve this problem, we need to find the paths from one to another node. For this, we will find the XOR of all nodes in the path from the ... Read More

XOR of Prime Frequencies of Characters in a String in C++

sudhir sharma
Updated on 20-Apr-2020 11:41:56

207 Views

In this problem, we are given a string of characters, our task is to print the XOR of frequencies of characters of the string whose frequency of occurrence is a prime number.Let’s take an example to understand the problem, Input − TutorialsPointOutput −Here, we will check the frequency of occurrence of each character of the string and then find XOR of all the characters whose frequency is a prime number. For this will create an array of prime frequencies. Then we will store frequencies of characters of a string in a map and then matching with prime frequency array. If ... Read More

XOR of Sum of every possible pair of an array in C++

sudhir sharma
Updated on 20-Apr-2020 11:39:02

276 Views

In this problem, we are given an array of n elements. Our task is to generate a sequence of size n*n whose elements are the sum of a pair of all elements of A with itself. And print the xor elements of this sum array formed.Let’s take an example to understand the problem, Input − A (1, 4, 5)Output − 0Explanation −B (1+1, 1+4, 1+5, 4+1, 4+4, 4+5, 5+1, 5+4, 5+5) B(2, 5, 6, 5, 8, 9, 6, 9, 10) Xor of all values = 2^5^6^5^8^9^6^9^10 = 0.To solve this problem, we need to know some properties of Xor. The ... Read More

Write a function to get Nth node in a Linked List in C++

sudhir sharma
Updated on 20-Apr-2020 11:27:28

716 Views

Here, we are given a linked list and an index. We have to write a function to get Nth node in a linked list.Let’s take an example to understand the problem, Inputlinked list = 34 -> 4 -> 9 -> 1 , n = 2Output9To go to the node specified by n. We will go node by node in the linked list and increase the index count until the required nth position is reached.Program to illustrate the program, Example Live Demo#include using namespace std; class Node{    public:    int data;    Node* next; }; void insertNode(Node** head_ref, int new_data) ... Read More

Write a program that produces different results in C and C++ programming

sudhir sharma
Updated on 20-Apr-2020 11:24:53

179 Views

Write a program that compiler and runs both in c and c++ and produces different results.There are multiple types of programs that give different results when compiled in c and c++.i. Using character literals− c and c++ both treat characters differently. In C, they are treated as integer literals whereas, in C++, they are treated as characters.Example Live Demo#include int main(){    printf("%d", sizeof('a'));    return 0; }OutputC : 4 C++: 1ii. Use of binary number − binary values are not considered as binary in c, instead treat it as integer. But in c++, they are treated as binary.Example Live Demo#include int ... Read More

Write a program to reverse an array or string in C++

sudhir sharma
Updated on 20-Apr-2020 11:15:49

1K+ Views

Here, we are given an array or a string of characters. We will create a program to reverse the elements of an array or string.Let’s take an example to understand the problem, Inputarray = {2, 5, 7, 1, 9}Output{9, 1, 7, 5, 2}Inputstring = “Hello!”Output!0lleHTo create a program, we will loop through the elements of the array/string(both work in the same way). Taking one variable for start and one of end. And swap both elements. Increment the start variable and decrement the end variable. The swapping will continue till start variable’s value is less than end variable.The program can be ... Read More

Bypass Anti-virus using Veil Framework

Ajay yadav
Updated on 20-Apr-2020 06:03:20

1K+ Views

This article is intended to demonstrate, how to bypass the anti-virus detection using the Veil framework, as it is a collection of tools designed for use during penetration testing. It currently consists of the following modules −Veil-Evasion − a tool to generate antivirus-evading payloads using a variety of techniques and languagesVeil-Catapult − a psexec-style payload delivery system that integrates Veil-EvasionVeil-PowerView − a powershell tool to gain network situational awareness on Windows domainsVeil-Pillage − a modular post-exploitation framework that integrates Veil-EvasionRequirementsTo install the Veil- Framework, you are supposed to configure the latest Python packages into your machine.How to InstallThe important point ... Read More

Write an Efficient C Program to Reverse Bits of a Number in C++

sudhir sharma
Updated on 17-Apr-2020 13:29:53

1K+ Views

In this problem, we are given an unsigned integer n. Our task is to create a program that returns the number which is generated by reversing all the bits of the number.Let’s take an example to understand the problem, Inputn = 1Output2147483648Explanationbinary of 1 is 000...0001, the reverse is 100...0000.To solve this problem, we simple solution will be using a simple formula. We will loop through the binary of the number. And find the position of the set bit in the number lets say it i. The result will be calculated using the formula, ((total_number_of_bits) - 1) - iProgram to ... Read More

Write an iterative O(Log y) function for pow(x, y) in C++

sudhir sharma
Updated on 17-Apr-2020 13:57:56

561 Views

In this problem, we are given two integers x and y. Our task is to create a function that will be equivalent to pow(x, y) using an iterative approach that will complete the task in time complexity of 0(Log y).Let’s take a few examples to understand the problem, Inputx = 7 , y = 3Output343The iterative function for pow(x, y) will iterate and update the result for odd values of y multiplying it by x and update x to x2 at every iteration.Program to show the implementation of the solutionExample Live Demo#include using namespace std; void calcPower(int x, unsigned int ... Read More

Advertisements