Programming Articles

Page 2407 of 2547

Replacing words with asterisks in C++

Ajay yadav
Ajay yadav
Updated on 29-Nov-2019 779 Views

This aim of this program to replace a particular word with asterisks in the string by using the c++ programming code. The essential function of vector and string class essay a key role to achieve the prospective results. The algorithm is as follows;AlgorithmSTART    Step-1: Input string    Step-2 Split the string into words and store in array list    Step-3: Iterate the loop till the length and put the asterisk into a variable    Step-4: Traverse the array foreah loop and compare the string with the replaced word    Step-5: Print ENDNow, the following code is carved out based ...

Read More

Write a program for Happy Woman's Day in c++

Ajay yadav
Ajay yadav
Updated on 29-Nov-2019 527 Views

The woman day which is celebrated on 7th October worldwide is carved into a c++ programming code as following;Example#include using namespace std; int main(){    // Initializing size of    // design    int n = 5;    // Loop to print Circle    // (Upper part of design)    // Outer loop to    // control height of    // design    for (int i = 0; i

Read More

How to check if element exists in the visible DOM?

Ayush Gupta
Ayush Gupta
Updated on 27-Nov-2019 810 Views

We can use the Node.contains method to do this check. The Node.contains() method returns a Boolean value indicating whether a node is a descendant of a given node, i.e. the node itself, one of its direct children (childNodes), one of the children's direct children, and so on.ExampleFor example, you are looking for an element with id test, you can use the following −const elem = document.querySelector('#test'); console.log(document.body.contains(elem));This will log true or false based on whether the element is present in the visible DOM.

Read More

The Pros and Cons of Using Ajax

Ayush Gupta
Ayush Gupta
Updated on 27-Nov-2019 6K+ Views

Ajax is a set of web development techniques using many web technologies on the client-side to create asynchronous web applications. With Ajax, web applications can send and retrieve data from a server asynchronously without interfering with the display and behavior of the existing page.Any other technology Ajax also has its own pros and cons. Let's look at some of those.Pros −Allows applications to render without data and fill data as the application gets it from the server.Gives platform independence to application developersFaster page rendersMore responsive applicationsNo rerenders of whole pages are needed to update only a single area.Cons−Any user whose ...

Read More

How to Send and Receive JSON Data to and from the Server

Ayush Gupta
Ayush Gupta
Updated on 27-Nov-2019 3K+ Views

JavaScript can send network requests to the server and load JSON. JS does this using something called AJAX. AJAX stands for Asynchronous JavaScript and XML. JS has an API, fetch, to GET(receive) and POST(send) information to the server.You can use fetch to GET JSON data in the following way −Exampleconst URL = 'https://jsonplaceholder.typicode.com/todos/1' // Send a GET request without any data to the server fetch(URL, {method: "GET"}) // Get the JSON data from the raw response    .then(res => res.json()) // Print the result    .then(console.log)OutputThis will give the output −{    "userId": 1,    "id": 1,    "title": "delectus ...

Read More

Minimum operations required to set all elements of binary matrix in C++

Narendra Kumar
Narendra Kumar
Updated on 22-Nov-2019 312 Views

Problem statementGiven a binary matrix of N rows and M columns. The operation allowed on the matrix is to choose any index (x, y) and toggle all the elements between the rectangle having top-left as (0, 0) and bottom-right as (x-1, y-1). Toggling the element means changing 1 to 0 and 0 to 1. The task is to find minimum operations required to make set all the elements of the matrix i.e make all elements as 1.ExampleIf input matrix is {0, 0, 0, 1, 1}    {0, 0, 0, 1, 1}    {0, 0, 0, 1, 1}    {1, 1, ...

Read More

Minimum operations to make the MEX of the given set equal to x in C++

Narendra Kumar
Narendra Kumar
Updated on 22-Nov-2019 663 Views

Problem statementGiven a set of n integers, perform minimum number of operations (you can insert/delete elements into/from the set) to make the MEX of the set equal to x (that is given).Note − The MEX of a set of integers is the minimum non-negative integer that doesn’t exist in it. For example, the MEX of the set {0, 2, 4} is 1 and the MEX of the set {1, 2, 3} is 0ExampleIf n = 5 and x = 3 and array is {0, 4, 5, 6, 7} then we require minimum 2 operationsAlgorithmThe approach is to see that in ...

Read More

Minimum operations to make XOR of array zero in C++

Narendra Kumar
Narendra Kumar
Updated on 22-Nov-2019 614 Views

Problem statementWe are given an array of n elements. The task is to make XOR of whole array 0. We can do following to achieve this.We can select any one of the element −After selecting element, we can either increment or decrement it by 1.We need to find the minimum number of increment/decrement operation required for the selected element to make the XOR sum of whole array zeroExampleIf arr[] = {2, 4, 7} then 1 operation is required −Select element 2Decrement it by 1Now array becomes {3, 4, 7} and its XOR is 0AlgorithmFind the XOR of whole arrayNow, suppose ...

Read More

Minimum partitions of maximum size 2 and sum limited by given value in C++

Narendra Kumar
Narendra Kumar
Updated on 22-Nov-2019 172 Views

Problem statementGiven an array arr[] of positive numbers, find minimum number of sets in array which satisfy following property, A set can contain maximum two elements in it. The two elements need not to be contiguous.Sum of elements of set should be less than or equal to given Key. It may be assumed that given key is greater than or equal to the largest array element.ExampleIf arr[] = {1, 2, 3, 4} and k = 5 then following 2 pairs can be created −{1, 4} and {2, 3}AlgorithmSort the arrayBegin two pointers from two corners of the sorted array. If ...

Read More

Minimum Players required to win the game in C++

Narendra Kumar
Narendra Kumar
Updated on 22-Nov-2019 232 Views

Problem statementGiven N questions and K options for each question, where 1

Read More
Showing 24061–24070 of 25,466 articles
Advertisements