In this problem, we are given linked list consisting of two pointer nodes, right and down.Right node is the main linked list pointer.Down node is for secondary linked list starting with that node.All the linked lists are sorted.Our task is to create a program to flatten a linked list and the resulting list will itself be a sorted one.Let’s take an example to understand the problemInputOutput1-> 9-> 8 -> 4 -> 6-> 7-> 2-> 3-> 5Solution ApproachA solution to the problem is using merge sort for a linked list. This method will merge the lists recursively in a sorted order ... Read More
In this problem, we are given a multilevel linked list. Our task is to create a program to flatten a multilevel linked list.The flattening operation is done in such a way that the first level nodes will occur first in the linked list and then the second level nodes will occur.Multilevel linked list is a multi-dimensional data structure in which every node of the linked list has two link pointers, one a link to the next node and one to the child list with one or more nodes. This child pointer may or may not point to other list nodes.ExampleLet’s ... Read More
In this problem, we will see the implementation and types of Fizz-Bizz problem.Fizz Buzz − it is a simple programming problem in which the programmer changes the occurrence o all multiples of 3 by ‘Fizz’ and all multiples of 5 by ‘Buzz’ in the numbers from 1 to 100.Let’s take an example to understand the problem1, 2, 'Fizz', 4, 'Buzz', 'Fizz' , 7, 8, 'Fizz' , 'Buzz', 11, 'Fizz' , 13, 14, 'Fizz Buzz' , 16, 17, 'Fizz' , 19, 'Buzz', ....Solution ApproachA simple approach to solving the problem is by simply using a loop from 1 to 100. And ... Read More
In this problem, we are given three integer values W, n, m denoting the length of wall W, size of shelves n, and m. Our task is To Create a Program to solve the Fitting Shelves Problem.We need to find a way to fit shelves in such a way that the space left after fitting shelves is minimized. A secondary constrain while solving is the cost of making, the larger shelves are more cost-effective so, we need to give them a priority.The output should be in the following form, Number of n size shelves number of m size shelves space ... Read More
The req.method property contains a string that corresponds to the HTTP methods of the request which are GET, POST, PUT, DELETE, and so on...These methods are based upon the requests sent by the user. All the above methods have different use-cases.Syntaxreq.methodExample 1Create a file with the name "reqMethod.js" and copy the following code snippet. After creating the file, use the command "node reqMethod.js" to run this code as shown in the example below −// req.method Property Demo Example // Importing the express & cookieParser module var cookieParser = require('cookie-parser'); var express = require('express'); // Initializing the express and ... Read More
The router.route() method returns the instance of a single route which can be used to handle the HTTP verbs further with the optional middleware. This method can be used to avoid duplicate route naming and therefore the typing errors.Syntaxrouter.route( path )Example 1Create a file with the name "routerRoute.js" and copy the following code snippet. After creating the file, use the command "node routerRoute.js" to run this code as shown in the example below −// router.route() Method Demo Example // Importing the express module var express = require('express'); // Initializing the express and port number var app = express(); ... Read More
The res.attachment() method is used for setting the Content-Disposition header field to "attachment". If a filename is passed, then it sets the Content-type based on the extension name that is retrieved from the res.type(). It sets the Content-Disposition "filename" field with the parameter.Syntaxres.attachment()Example 1Create a file with the name "resAttachment.js" and copy the following code snippet. After creating the file, use the command "node resAttachment.js" to run this code as shown in the example below −// res.attachment() Method Demo Example // Importing the express var express = require('express'); // Initializing the express and port number var app = ... Read More
The req.params property is an object that contains the properties which are mapped to the named route "parameters". For example, if you have a route as /api/:name, then the "name" property is available as req.params.name. The default value of this object is {}.Syntaxreq.paramsExample 1Create a file with the name "reqParams.js" and copy the following code snippet. After creating the file, use the command "node reqParams.js" to run this code as shown in the example below −// req.params Property Demo Example // Importing the express var express = require('express'); // Initializing the express and port number var app = ... Read More
The req.route property contains the recently matched route in a string format.Syntaxreq.routeExample 1Create a file with the name "reqRoute.js" and copy the following code snippet. After creating the file, use the command "node reqRoute.js" to run this code as shown in the example below −// req.route Property Demo Example // Importing the express module var express = require('express'); // Initializing the express and port number var app = express(); // Initializing the router from express var router = express.Router(); var PORT = 3000; // Defining an endpoint and checking req.route app.get('/api', function (req, res) { ... Read More
The res.location() method is used for setting the response Location HTTP header to the specified path parameter. Setting the location does not end the process, one can still send some response after setting the location header.Syntaxres.location( path )Example 1Create a file with the name "resLocation.js" and copy the following code snippet. After creating the file, use the command "node resLocation.js" to run this code as shown in the example below −// res.location(path) Method Demo Example // Importing the express module var express = require('express'); // Initializing the express and port number var app = express(); // Initializing ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP