In this tutorial, we are going to write a program that finds the pair whose sum is equal to the given number in the binary search tree.We are going to store and values of trees in two different lists to find the pairs. Let's see the steps to solve the problem.Create a struct node for a binary tree.Write a function to insert a new node into the binary search tree.Remember, in the binary search tree all the elements that are less than root are smaller, and right are larger.Initialize two empty lists to store the left and right nodes of ... Read More
In this tutorial, we are going to find a number whose some including with its digits is equal to the given number N.The idea is simple, we are going to check the left and right 100 numbers of the given number. It won't lie out that bound as N ≤ 1000000000 and the sum won't exceed 100.Let's see the steps to solve the problem.Initialize the number.Write a loop that iterates 100 times.Get the n - i and n + i values.Find the sum of the digits and add them.If anyone of them is equal to the N, print them.ExampleLet's see ... Read More
In this tutorial, we are going to find the number that is divided into maximum elements in the given array.Let's see the steps to solve the problem.Initialize the array and a variable to store the result.Iterate over the array.Initialize the counter variable.Iterate over the array again.Increment the counter if the current element is divisible by the array element.Update the result if the current count is maximum.Print the result.ExampleLet's see the code. Live Demo#include using namespace std; int numberWithMaximumMultiples(int arr[], int n) { int result = -1; for (int i = 0; i < n; i++) { ... Read More
The working of Selenium webdriver is described in the below image −Source Img : https://www.tutorialspoint.com/what−is−web−driver−in−seleniumSelenium webdriver contains the below components −Selenium Binding Languages − Selenium can work on more than one language like Java, Python, C#, Ruby, and so on as it has the bindings for all these languages.JSON Wire Protocol − JavaScript Object Notation is called the JSON Wire Protocol. It dispatches data from the server to the page of the client. It is developed on REST API which carries information inside the HTTP servers.Browser Driver − Every browser has a driver with which it establishes communication. As a ... Read More
We can set a cookie to a specific domain in Selenium webdriver with Python. A cookie is used to hold information sent by the browser. A key−value pair format is utilized and it is like a message provided to the browser by the server.For cookie addition, the method add_cookie is used. The key and value are passed as parameters to the method. To get back all the cookies, get_cookies method is used. To get a specific cookie, the method get_cookie is used.To delete cookies, the method delete_all_cookies is used.Syntaxdriver.add_cookie({"Automation": "QA"}); c= driver.get_cookies(); driver.get_cookie({"Automation"); driver.delete_all_cookies();Examplefrom selenium import webdriver #set geckodriver.exe path ... Read More
The differences between Mocha and Selenium are listed below −VsFunctionalitiesMochaSeleniumPurposeIt is an easy, workable and popular JavaScript framework developed for Node.js.It is a free automation tool used for testing the web.LanguageBased on JavaScript.Can be used with multiple languages like Java, Python, C#, Ruby, JavaScript, and so on.UsageUsed for integration, unit and end to end testing.Used for web based automation testing.XUnit frameworkIt contains the XUnit reporter which yields an XML document.It cannot be used with XUnit Framework.BrowserSupports mostly Chrome and Firefox. It can be used for other browsers with certain challenges.Supports the majority of browsers like Chrome, Firefox, Safari, IE, and ... Read More
We can inspect HTTP response headers with Selenium webdriver. To verify the HTTP header, we should get the response from a source. Some of the HTTP response codes are listed below −5XX − Represents server concerns.4XX − Represents issues in resource detection.3XX − Represents response redirection.2XX − Represents correct ocde.The HttpURLConnection class is used to obtain the HTTP response code. To have a link to an URL, the method openConnection is used. Then, we have to use the setRequestMethod method and pass HEAD as parameter to it.The connect method is applied on the object of the HttpURLConnection class. Finally, the ... Read More
In this tutorial, we are going to solve the following problem.Given an array, find the number which is equal to the index. It's a straightforward problem.Iterate over the given array and return the index which is equal to the array element.ExampleLet's see the code. Live Demo#include using namespace std; int linearSearch(int arr[], int n) { for(int i = 0; i < n; i++) { if(arr[i] == i) { return i; } } return -1; } int main() { int arr[] = {10, 20, 30, 40, 50, 5, 60}; cout
In this tutorial, we are going to solve the following problem.Given an integer n, we have to find the (1n+2n+3n+4n)%5The number (1n+2n+3n+4n) will be very large if n is large. It can't be fit in the long integers as well. So, we need to find an alternate solution.If you solve the equation for the number 1, 2, 3, 4, 5, 6, 7, 8, 9 you will get 10, 30, 100, 354, 1300, 4890, 18700, 72354, 282340 values respectively.Observe the results of the equation carefully. You will find that the last digit of the equation result repeats for every 4th number. ... Read More
We can automatically download files from a pop up dialog using Selenium webdriver with Python. After clicking the download link, a dialog box appears for the user to select various options to Save the file.We have to programmatically configure the path where the download has to be performed such that every time the Firefox browser is launched, the Firefox profile is proper to perform the download at the desired location.Open the address bar of Firefox, and enter about:config and press Enter . All the browser preferences shall be available with Edit and Toggle buttons. We shall use the Firefox Options ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP