Found 7347 Articles for C++

Dumpster Diving/Trashing in C++

sudhir sharma
Updated on 22-Jan-2021 12:30:06

76 Views

Dumpster diving or trashing is a technique used in cyber security and information technology which is commonly used by hackers to extract data. It is based on the fact that “something which is worthless for someone can be of great usage for someone else”. It works based on the idiom, “One man’s trash is another man’s treasure”. Trashing refers to searching online trash (unused information) and finding out fruitful information about a business or person to use it to perform hacking related activities.This dumpster diving is used to gather information to try to hack or extract information of business using a phishing technique by pretending to be ... Read More

Dudeney Numbers in C++

sudhir sharma
Updated on 22-Jan-2021 12:29:45

476 Views

A mathematical number defined in number theory in a given number base is a natural number equal to the perfect cube of another natural number such that the digit sum of the first natural number is equal to the digit sum of the second number(wikipedia).The number was found by Henry Dudeney. Its mathematical formula is −Here, we are given an integer n. Our task is to check whether the given number n is a dudeney number or not. Let’s take an example to understand the problem, Input: N = 17592Output: NoExplanation:  The given number is not a dudney number.Solution Approach −The solution lies ... Read More

Dual Mode operations in OS in C++

sudhir sharma
Updated on 22-Jan-2021 12:29:14

3K+ Views

Every system works on operations mainly in two modes to safeguard hardware’s computation. The two modes are −User ModeKernel ModeUser Mode −The OS mode in which all the user applications and programs will run. Here, the user instructions are worked on and softwares like playing music is run.Kernel Mode −The OS mode in which the hardware loads and its computations are performed. Only privileged instructions are allowed to run in kernel mode. Some common privileged instructions are −Input-Output ManagementSwitching modes between user mode and kernel mode.Interrupt managementDual Mode in OS is the switching of modes between the two modes and switching of mode ... Read More

Check if possible to move from given coordinate to desired coordinate in C++

Arnab Chakraborty
Updated on 19-Jan-2021 05:29:20

227 Views

Suppose we have two coordinates (sx, sy), and (tx, ty), we have to check whether we can move from starting point to ending point or not. Here we can move consists of taking a point (x, y) and transforming it to either (x, x+y) or (x+y, y).So if the inputs are (1, 1) and (4, 5), then the answer will be true, this is because move (1, 1) to (2, 1), then (3, 1), then (4, 1), then (4, 5).To solve this, we will follow these steps −while tx > sx and ty > sy, do −if tx > ty, ... Read More

Check if it is possible to return to the starting position after moving in the given directions in C++

Arnab Chakraborty
Updated on 18-Jan-2021 13:33:52

127 Views

Suppose we are at position (0, 0) We have a string represents consecutive directions using four letters. We have to check whether we can return at (0, 0) position after considering all of the given directions. The symbols areE for eastW for westN for northS for south.So, if the input is like "EENWWS", then the output will be true, move east two units, then go north, then west two units then again south, so this is the starting position.To solve this, we will follow these steps −l := size of moves arrayif l is same as 0, then −return truelft ... Read More

Check if a string follows anbn pattern or not in C++

Arnab Chakraborty
Updated on 18-Jan-2021 11:49:45

254 Views

Suppose, we are given a string that is made of only two letters a and b. We have to find out if the string is of the form anbn, or in other words it contains n number of a's followed by n number of b's. If true, we return 1 otherwise 0.So, if the input is like "aaaaaaaaaaaabbbbbbbbbbbb", then the output will be true.To solve this, we will follow these steps −length := length of input_stringfor initialize i := 0, when i < length, update (increase i by 1), do &minusif input_string[i] is not equal to 'a', then −Come out ... Read More

Check if a string contains a palindromic sub-string of even length in C++

Arnab Chakraborty
Updated on 18-Jan-2021 11:46:50

222 Views

Suppose, we are given a string that contains only lowercase letters. Our task is to find if there exists a substring in the given string that is a palindrome and is of even length. If found, we return 1 otherwise 0.So, if the input is like "afternoon", then the output will be true.To solve this, we will follow these steps −for initialize x := 0, when x < length of string - 1, increase x by 1, do −if string[x] is same as string[x + 1], then:return truereturn falseExample (C++)Let us see the following implementation to get better understanding − Live ... Read More

Check if a string can become empty by recursively deleting a given sub-string in C++

Arnab Chakraborty
Updated on 18-Jan-2021 11:45:26

144 Views

Suppose, we are given two strings, str1 and str2. str2 is a substring of str1, and we can delete str2 from str1. It is possible, that the string str2 appears multiple times in str1. Our goal here is to find out if str1 becomes a null string if we keep removing str2 from str1 multiple times. If it is possible we return 1, otherwise 0.So, if the input is like str1 = "CCCPPPPPP", str2 = "CPP"; then the output will be true.To solve this, we will follow these steps −while size of str1 > 0, do −index := return the ... Read More

How to get website links using Invoke-WebRequest in PowerShell?

Chirag Nagrekar
Updated on 18-Jan-2021 07:29:34

4K+ Views

To get the links present on the website using PowerShell, we can first retrieve the data from the webpage using the Invoke-WebRequest cmdlet.$req = Invoke-WebRequest -uri "https://theautomationcode.com" $reqOutputTo retrieve only links we can use that property and there you will also find some sub-properties like InnerHTML, Innertext, href, etc as shown in the output.$req = Invoke-WebRequest -uri "https://theautomationcode.com" $req.LinksOutputinnerHTML : Scripts innerText : Scripts outerHTML : Scripts outerText : Scripts tagName : A href : https://theautomationcode.com/scripts/ We need only links so we will use the href property.$req.Links | Select -ExpandProperty hrefOutputhttps://theautomationcode.com/2020/11/ https://theautomationcode.com/author/chiragce17/ ... Read More

Diameter of a Binary Tree in O(n) [A new method] in C++?

AmitDiwan
Updated on 16-Jan-2021 10:58:03

299 Views

The diameter of a binary tree is the (left_height + right_height + 1) for each node. So in this method we will calculate (left_height + right_height + 1) for each node and update the result . The time complexity here stays O(n).Let us first define the struct that would represent a tree node that contains the data and its left and right node child. If this is the first node to be created then it’s a root node otherwise a child node.struct Node {    int data;    struct Node *leftChild, *rightChild; };Next we create our newNode(int data) function that ... Read More

Advertisements