title
stringlengths
3
221
text
stringlengths
17
477k
parsed
listlengths
0
3.17k
Nested list comprehension in python
A nested list is a list within a list. Python provides features to handle nested list gracefully and apply common functions to manipulate the nested lists. In this article we will see how to use list comprehension to create and use nested lists in python. Creating a matrix involves creating series of rows and columns. ...
[ { "code": null, "e": 1443, "s": 1187, "text": "A nested list is a list within a list. Python provides features to handle nested list gracefully and apply common functions to manipulate the nested lists. In this article we will see how to use list comprehension to create and use nested lists in pytho...
Python | URL shortener using tinyurl API
26 Aug, 2019 There are multiple APIs (e.g-bitly API, etc.) available for URL shortening service but in this article, we will be using Tinyurl API to shorten URLs. Though tinyURL has not officially released its API but we are going to use it unofficially. Here, we can put as input any number of URLs at a time and get th...
[ { "code": null, "e": 54, "s": 26, "text": "\n26 Aug, 2019" }, { "code": null, "e": 204, "s": 54, "text": "There are multiple APIs (e.g-bitly API, etc.) available for URL shortening service but in this article, we will be using Tinyurl API to shorten URLs." }, { "code": nu...
Evolution of Networks
03 Jan, 2020 Need of a Network: An “network” additionally enables associated PCs to share documents and information and also equipment assets, i.e., scanners, plotters, projectors and storage devices, making it simpler to gather and administer data, and enabling clients to work together. The system was simply not advan...
[ { "code": null, "e": 52, "s": 24, "text": "\n03 Jan, 2020" }, { "code": null, "e": 328, "s": 52, "text": "Need of a Network: An “network” additionally enables associated PCs to share documents and information and also equipment assets, i.e., scanners, plotters, projectors and sto...
GATE | GATE-CS-2015 (Set 2) | Question 20
28 Jun, 2021 A binary tree T has 20 leaves. The number of nodes in T having two children is(A) 18(B) 19(C) 17(D) Any number between 10 and 20Answer: (B)Explanation: Sum of all degrees = 2 * |E|. Here considering tree as a k-ary tree : Sum of degrees of leaves + Sum of degrees for Internal Node except root + Root's deg...
[ { "code": null, "e": 53, "s": 25, "text": "\n28 Jun, 2021" }, { "code": null, "e": 205, "s": 53, "text": "A binary tree T has 20 leaves. The number of nodes in T having two children is(A) 18(B) 19(C) 17(D) Any number between 10 and 20Answer: (B)Explanation:" }, { "code": ...
How to find the sum of Particular Column in PySpark Dataframe
29 Jun, 2021 In this article, we are going to find the sum of PySpark dataframe column in Python. We are going to find the sum in a column using agg() function. Let’s create a sample dataframe. Python3 # importing moduleimport pyspark # importing sparksession from pyspark.sql modulefrom pyspark.sql import SparkSessio...
[ { "code": null, "e": 28, "s": 0, "text": "\n29 Jun, 2021" }, { "code": null, "e": 177, "s": 28, "text": "In this article, we are going to find the sum of PySpark dataframe column in Python. We are going to find the sum in a column using agg() function. " }, { "code": null...
Difference between SOP and POS in Digital Logic
03 Jun, 2021 In digital logic, the inputs and output of a function are in the form of binary numbers (boolean values) i.e., the values are either zero (0) or one (1). Therefore, digital logic is also known as ‘Boolean logic’. These inputs and output can be termed as ‘Boolean Variables’. The output boolean variable of a...
[ { "code": null, "e": 53, "s": 25, "text": "\n03 Jun, 2021" }, { "code": null, "e": 468, "s": 53, "text": "In digital logic, the inputs and output of a function are in the form of binary numbers (boolean values) i.e., the values are either zero (0) or one (1). Therefore, digital l...
How can I update MySQL table after quoting the values of a column with a single quote?
As we know that with the help of QUOTE() function we can put the values of a column in single quotes. By using QUOTE() function with UPDATE clause we can update the table having quoted values. We need to give column name as the parameter of QUOTE() function. Following example will update the table ‘examination_btech’ a...
[ { "code": null, "e": 1568, "s": 1187, "text": "As we know that with the help of QUOTE() function we can put the values of a column in single quotes. By using QUOTE() function with UPDATE clause we can update the table having quoted values. We need to give column name as the parameter of QUOTE() func...
Python MongoDB - Query
While retrieving using find() method, you can filter the documents using the query object. You can pass the query specifying the condition for the required documents as a parameter to this method. Following is the list of operators used in the queries in MongoDB. Following example retrieves the document in a collection...
[ { "code": null, "e": 3536, "s": 3339, "text": "While retrieving using find() method, you can filter the documents using the query object. You can pass the query specifying the condition for the required documents as a parameter to this method." }, { "code": null, "e": 3603, "s": 3536...
Python | Remove additional spaces in list
08 Apr, 2019 Sometimes, we have a list that contains strings and spaces in between them. We desire to have uniformity, so that later if we decide them, we just have single spaces between the lists. Hence its sometimes necessary to remove the additional unnecessary spaces between the words in a list. Let’s discuss certa...
[ { "code": null, "e": 28, "s": 0, "text": "\n08 Apr, 2019" }, { "code": null, "e": 316, "s": 28, "text": "Sometimes, we have a list that contains strings and spaces in between them. We desire to have uniformity, so that later if we decide them, we just have single spaces between t...
Python | Print unique rows in a given boolean matrix using Set with tuples
26 Dec, 2017 Given a binary matrix, print all unique rows of the given matrix. Order of row printing doesn’t matter. Examples: Input: mat = [[0, 1, 0, 0, 1], [1, 0, 1, 1, 0], [0, 1, 0, 0, 1], [1, 1, 1, 0, 0]] Output: (1, 1, 1, 0, 0) (0, 1, 0, 0, 1) ...
[ { "code": null, "e": 28, "s": 0, "text": "\n26 Dec, 2017" }, { "code": null, "e": 132, "s": 28, "text": "Given a binary matrix, print all unique rows of the given matrix. Order of row printing doesn’t matter." }, { "code": null, "e": 142, "s": 132, "text": "Ex...
Mediator Method – Python Design Pattern
07 Oct, 2021 Mediator Method is a Behavioral Design Pattern that allows us to reduce the unordered dependencies between the objects. In a mediator environment, objects take the help of mediator objects to communicate with each other. It reduces coupling by reducing the dependencies between communicating objects. The me...
[ { "code": null, "e": 28, "s": 0, "text": "\n07 Oct, 2021" }, { "code": null, "e": 442, "s": 28, "text": "Mediator Method is a Behavioral Design Pattern that allows us to reduce the unordered dependencies between the objects. In a mediator environment, objects take the help of med...
QTP - Environment Variables
QTP environment variables are special types of variables that can be accessed by all actions, function libraries, and recovery scenarios. There are in-built environment variables for Windows that are available to all the applications running on that particular system, but QTP environment variables are only available to...
[ { "code": null, "e": 2622, "s": 2256, "text": "QTP environment variables are special types of variables that can be accessed by all actions, function libraries, and recovery scenarios. There are in-built environment variables for Windows that are available to all the applications running on that par...
For Loop in Scala
20 Jul, 2021 In Scala, for loop is also known as for-comprehensions. A for loop is a repetition control structure which allows us to write a loop that is executed a specific number of times. The loop enables us to perform n number of steps together in one line. Syntax: for(w <- range){ // Code.. } Here, w is a variab...
[ { "code": null, "e": 54, "s": 26, "text": "\n20 Jul, 2021" }, { "code": null, "e": 304, "s": 54, "text": "In Scala, for loop is also known as for-comprehensions. A for loop is a repetition control structure which allows us to write a loop that is executed a specific number of tim...
An interesting time complexity question
30 Oct, 2015 What is the time complexity of following function fun()? int fun(int n){ for (int i = 1; i <= n; i++) { for (int j = 1; j < n; j += i) { // Some O(1) task } } } For i = 1, the inner loop is executed n times.For i = 2, the inner loop is executed approximately ...
[ { "code": null, "e": 52, "s": 24, "text": "\n30 Oct, 2015" }, { "code": null, "e": 109, "s": 52, "text": "What is the time complexity of following function fun()?" }, { "code": "int fun(int n){ for (int i = 1; i <= n; i++) { for (int j = 1; j < n; j += i)...
Python | Functions | Question 7
28 Jun, 2021 What is the output of the following program : import resentence = 'horses are fast'regex = re.compile('(?P<animal>\w+) (?P<verb>\w+) (?P<adjective>\w+)')matched = re.search(regex, sentence)print(matched.groupdict()) (A) {‘animal’: ‘horses’, ‘verb’: ‘are’, ‘adjective’: ‘fast’}(B) (‘horses’, ‘are’, ‘fast’)(C...
[ { "code": null, "e": 52, "s": 24, "text": "\n28 Jun, 2021" }, { "code": null, "e": 98, "s": 52, "text": "What is the output of the following program :" }, { "code": "import resentence = 'horses are fast'regex = re.compile('(?P<animal>\\w+) (?P<verb>\\w+) (?P<adjective>\\w...
Tryit Editor v3.6 - Show Python
f = open("demofile.txt", "r")
[]
How to Join NumPy Arrays ? - onlinetutorialspoint
PROGRAMMINGJava ExamplesC Examples Java Examples C Examples C Tutorials aws JAVAEXCEPTIONSCOLLECTIONSSWINGJDBC EXCEPTIONS COLLECTIONS SWING JDBC JAVA 8 SPRING SPRING BOOT HIBERNATE PYTHON PHP JQUERY PROGRAMMINGJava ExamplesC Examples Java Examples C Examples C Tutorials aws In this tutorial we will see how to join diff...
[ { "code": null, "e": 158, "s": 123, "text": "PROGRAMMINGJava ExamplesC Examples" }, { "code": null, "e": 172, "s": 158, "text": "Java Examples" }, { "code": null, "e": 183, "s": 172, "text": "C Examples" }, { "code": null, "e": 195, "s": 183, ...
What are the various return types of a controller action in C# ASP.NET WebAPI?
The Web API action method can have following return types. Void Void Primitive Type/Complex Type Primitive Type/Complex Type HttpResponseMessage HttpResponseMessage IHttpActionResult IHttpActionResult Void − It's not necessary that all action methods must return something. It can have void return type. using DemoWebApp...
[ { "code": null, "e": 1121, "s": 1062, "text": "The Web API action method can have following return types." }, { "code": null, "e": 1126, "s": 1121, "text": "Void" }, { "code": null, "e": 1131, "s": 1126, "text": "Void" }, { "code": null, "e": 1159,...
Display percentage above bar chart in Matplotlib - GeeksforGeeks
04 Jul, 2021 In this article, we are going to discuss how we can plot a bar chart using the Matplotlib library and display percentages above each bar in the bar chart. For the sake of explanation, we are going to take an example of the runs scored by former Indian Captain MS Dhoni across all the formats, and then we wi...
[ { "code": null, "e": 25555, "s": 25527, "text": "\n04 Jul, 2021" }, { "code": null, "e": 25710, "s": 25555, "text": "In this article, we are going to discuss how we can plot a bar chart using the Matplotlib library and display percentages above each bar in the bar chart." }, ...
Octal numbers in c - GeeksforGeeks
29 Aug, 2017 There are some less known facts in C related to octal numbers. Let us look at the below example code first. Examples: // program to show octal number interpretation#include <stdio.h> int main(){ int x = 012; printf("%d", x); return 0;} Output: 10 Surprisingly the output is not 12. This happens b...
[ { "code": null, "e": 25705, "s": 25677, "text": "\n29 Aug, 2017" }, { "code": null, "e": 25813, "s": 25705, "text": "There are some less known facts in C related to octal numbers. Let us look at the below example code first." }, { "code": null, "e": 25823, "s": 25...
KNN Algorithm: When? Why? How?. KNN: K Nearest Neighbour is one of the... | by Aditya Kumar | Towards Data Science
KNN: K Nearest Neighbor is one of the fundamental algorithms in machine learning. Machine learning models use a set of input values to predict output values. KNN is one of the simplest forms of machine learning algorithms mostly used for classification. It classifies the data point on how its neighbor is classified. KN...
[ { "code": null, "e": 365, "s": 47, "text": "KNN: K Nearest Neighbor is one of the fundamental algorithms in machine learning. Machine learning models use a set of input values to predict output values. KNN is one of the simplest forms of machine learning algorithms mostly used for classification. It...
Conditionally Create or Assign Columns on Pandas DataFrames | by Louis Chan | Towards Data Science
Python, arguably the coolest programming language these days (thanks for Machine Learning and Data Science), is not very well known for its efficiency when compared with one of the best programming language — C. An example of this would be conditional logics. When developing machine learning models, it is quite common ...
[ { "code": null, "e": 921, "s": 171, "text": "Python, arguably the coolest programming language these days (thanks for Machine Learning and Data Science), is not very well known for its efficiency when compared with one of the best programming language — C. An example of this would be conditional log...
Add padding to a string in Python - GeeksforGeeks
15 Dec, 2021 Inserting non-informative characters to a string is known as Padding. The insertion can be done anywhere on the string. String padding is useful for output formatting and alignment of strings while printing. Even for displaying values like a table string Padding is required. The three most commonly used S...
[ { "code": null, "e": 24444, "s": 24416, "text": "\n15 Dec, 2021" }, { "code": null, "e": 24721, "s": 24444, "text": "Inserting non-informative characters to a string is known as Padding. The insertion can be done anywhere on the string. String padding is useful for output formatt...
Turn Python Scripts into Beautiful ML Tools | by Adrien Treuille | Towards Data Science
In my experience, every nontrivial machine learning project is eventually stitched together with bug-ridden and unmaintainable internal tools. These tools — often a patchwork of Jupyter Notebooks and Flask apps — are difficult to deploy, require reasoning about client-server architecture, and don’t integrate well with ...
[ { "code": null, "e": 424, "s": 46, "text": "In my experience, every nontrivial machine learning project is eventually stitched together with bug-ridden and unmaintainable internal tools. These tools — often a patchwork of Jupyter Notebooks and Flask apps — are difficult to deploy, require reasoning ...
How to find residual variance of a linear regression model in R?
The residual variance is the variance of the values that are calculated by finding the distance between regression line and the actual points, this distance is actually called the residual. Suppose we have a linear regression model named as Model then finding the residual variance can be done as (summary(Model)$sigma)*...
[ { "code": null, "e": 1386, "s": 1062, "text": "The residual variance is the variance of the values that are calculated by finding the distance between regression line and the actual points, this distance is actually called the residual. Suppose we have a linear regression model named as Model then f...
Set width between table cells with CSS
The border-spacing specifies the width between table cells. It can take either one or two values; these should be units of length. You can try to run the following code to set the width of table cells: <html> <head> <style> table.one { border-collapse:separate; width:300px; ...
[ { "code": null, "e": 1193, "s": 1062, "text": "The border-spacing specifies the width between table cells. It can take either one or two values; these should be units of length." }, { "code": null, "e": 1264, "s": 1193, "text": "You can try to run the following code to set the wi...
How to Set up Account Linking in Amazon Alexa with Amazon Cognito OAuth2 Authorization Grant | by Chathurangi Shyalika | Towards Data Science
Amazon Alexa, is the virtual assistant AI technology developed by Amazon which was initially released in 2014. It’s one of the most creative designs by Amazon so far. Alexa awesomely performs activities like voice interaction, music playback, making to-do lists, setting alarms, streaming podcasts, providing weather, tr...
[ { "code": null, "e": 339, "s": 172, "text": "Amazon Alexa, is the virtual assistant AI technology developed by Amazon which was initially released in 2014. It’s one of the most creative designs by Amazon so far." }, { "code": null, "e": 600, "s": 339, "text": "Alexa awesomely per...
Setting the aspect ratio of a 3D plot in Matplotlib
To set the aspect ratio of a 3D plot in matplotlib, we can take the following steps− Using figure() method, create a new figure or activate an existing figure. Get the current axes, creating one if necessary, with projection='3d'. Create data points, R, Y and z, using numpy. Create a surface plot using R, Y and z. Set ...
[ { "code": null, "e": 1147, "s": 1062, "text": "To set the aspect ratio of a 3D plot in matplotlib, we can take the following steps−" }, { "code": null, "e": 1222, "s": 1147, "text": "Using figure() method, create a new figure or activate an existing figure." }, { "code": ...
Stemming Text with NLTK. Stemming is one of the most used... | by Ivo Bernardo | Towards Data Science
The ability to work with text data is a huge technological achievement that enables companies and organizations to deal with unstructured information and support decisions based on information that was extremely hard to collect and store in the past. Naturally, as computers don’t really understand characters and words ...
[ { "code": null, "e": 422, "s": 171, "text": "The ability to work with text data is a huge technological achievement that enables companies and organizations to deal with unstructured information and support decisions based on information that was extremely hard to collect and store in the past." }...
Concatenate two strings using Operator Overloading in Python - GeeksforGeeks
10 Jul, 2020 Operator Overloading refers to using the same operator to perform different tasks by passing different types of data as arguments. To understand how ‘+’ operator works in two different ways in python let us take the following example Python3 # taking two numbersa = 2b = 3 # using '+' operator add themc = ...
[ { "code": null, "e": 24408, "s": 24380, "text": "\n10 Jul, 2020" }, { "code": null, "e": 24642, "s": 24408, "text": "Operator Overloading refers to using the same operator to perform different tasks by passing different types of data as arguments. To understand how ‘+’ operator w...
IMS DB - Programming
An application program which includes DL/I calls cannot execute directly. Instead, a JCL is required to trigger the IMS DL/I batch module. The batch initialization module in IMS is DFSRRC00. The application program and the DL/I module execute together. The following diagram shows the structure of an application program...
[ { "code": null, "e": 2315, "s": 1946, "text": "An application program which includes DL/I calls cannot execute directly. Instead, a JCL is required to trigger the IMS DL/I batch module. The batch initialization module in IMS is DFSRRC00. The application program and the DL/I module execute together. ...
MySQL - Update Query
There may be a requirement where the existing data in a MySQL table needs to be modified. You can do so by using the SQL UPDATE command. This will modify any field value of any MySQL table. The following code block has a generic SQL syntax of the UPDATE command to modify the data in the MySQL table − UPDATE table_name ...
[ { "code": null, "e": 2523, "s": 2333, "text": "There may be a requirement where the existing data in a MySQL table needs to be modified. You can do so by using the SQL UPDATE command. This will modify any field value of any MySQL table." }, { "code": null, "e": 2635, "s": 2523, "...
Python | Working with buttons in Kivy - GeeksforGeeks
06 May, 2021 Kivy is a platform independent GUI tool in Python. As it can be run on Android, IOS, linux and Windows etc. Kivy provides you the functionality to write the code for once and run it on different platforms. It is basically used to develop the Android application, but it does not mean that it can not be used...
[ { "code": null, "e": 41163, "s": 41135, "text": "\n06 May, 2021" }, { "code": null, "e": 41498, "s": 41163, "text": "Kivy is a platform independent GUI tool in Python. As it can be run on Android, IOS, linux and Windows etc. Kivy provides you the functionality to write the code f...
XGBoost For Time Series Forecasting: Don’t Use It Blindly | by Michael Grogan | Towards Data Science
When modelling a time series with a model such as ARIMA, we often pay careful attention to factors such as seasonality, trend, the appropriate time periods to use, among other factors. However, when it comes to using a machine learning model such as XGBoost to forecast a time series — all common sense seems to go out t...
[ { "code": null, "e": 356, "s": 171, "text": "When modelling a time series with a model such as ARIMA, we often pay careful attention to factors such as seasonality, trend, the appropriate time periods to use, among other factors." }, { "code": null, "e": 629, "s": 356, "text": "H...
Program to find the Magnitude of a Vector - GeeksforGeeks
19 Apr, 2021 Given three integers representing the X, Y, and Z coordinates of a 3-D vector, the task is to find the magnitude of that vector. Example: Input: X = 1, Y = 2, Z = 2Output: 3Explanation: Magnitude of the vector is equal to √9 =3 Input: X = 0, Y = 4, Z = 3Output: 5 Approach: The magnitude of a vector can be ...
[ { "code": null, "e": 24326, "s": 24298, "text": "\n19 Apr, 2021" }, { "code": null, "e": 24455, "s": 24326, "text": "Given three integers representing the X, Y, and Z coordinates of a 3-D vector, the task is to find the magnitude of that vector." }, { "code": null, "e...
How to uninstall software using Package management in PowerShell?
There are mainly 3 methods by which you can uninstall software using PowerShell. WMI Method. WMI Method. Using Package provider Using Package provider Uninstallation String. Uninstallation String. Here, we will discuss the method to uninstall software using Package management. You can uninstall the software or packages...
[ { "code": null, "e": 1143, "s": 1062, "text": "There are mainly 3 methods by which you can uninstall software using PowerShell." }, { "code": null, "e": 1155, "s": 1143, "text": "WMI Method." }, { "code": null, "e": 1167, "s": 1155, "text": "WMI Method." }, ...
How to get the sum of the numbers in even positions in an array?
There are multiple ways to get the sum of numbers in even positions in an array. Let us look at 3 of these − We can directly use a for loop and get the sum. let arr = [1, 2, 3, 4, 5, 6]; let sum = 0; for(let i = 0; i < arr.length; i += 2) { sum += arr[i]; } console.log(sum); 9 In this method, instead of iterating ex...
[ { "code": null, "e": 1171, "s": 1062, "text": "There are multiple ways to get the sum of numbers in even positions in an array. Let us look at 3 of these −" }, { "code": null, "e": 1219, "s": 1171, "text": "We can directly use a for loop and get the sum." }, { "code": nul...
D3.js symbolTriangle symbol - GeeksforGeeks
07 Sep, 2020 The d3.symbolTriangle is a symbol type in D3.js. It is a square-shaped symbol type that can be used. Syntax: d3.symbolTriangle Example 1: <!DOCTYPE html><html><head> <meta charset="utf-8"> <script src= "https://d3js.org/d3.v5.min.js"> </script></head> <body> <h1 style="text-align: ...
[ { "code": null, "e": 24894, "s": 24866, "text": "\n07 Sep, 2020" }, { "code": null, "e": 24995, "s": 24894, "text": "The d3.symbolTriangle is a symbol type in D3.js. It is a square-shaped symbol type that can be used." }, { "code": null, "e": 25003, "s": 24995, ...
Swing Examples - Show Input Dialog with Text Box
Following example showcase how to get user input from a textbox in a dialog in swing based application. We are using the following APIs. JOptionPane − To create a standard dialog box. JOptionPane − To create a standard dialog box. JOptionPane.showInputDialog() − To show the message alert with input options. JOptionPane...
[ { "code": null, "e": 2143, "s": 2039, "text": "Following example showcase how to get user input from a textbox in a dialog in swing based application." }, { "code": null, "e": 2176, "s": 2143, "text": "We are using the following APIs." }, { "code": null, "e": 2223, ...
@Component,@Service,@Repository,@Controller in spring - onlinetutorialspoint
PROGRAMMINGJava ExamplesC Examples Java Examples C Examples C Tutorials aws JAVAEXCEPTIONSCOLLECTIONSSWINGJDBC EXCEPTIONS COLLECTIONS SWING JDBC JAVA 8 SPRING SPRING BOOT HIBERNATE PYTHON PHP JQUERY PROGRAMMINGJava ExamplesC Examples Java Examples C Examples C Tutorials aws In this tutorial, we are going to learn about...
[ { "code": null, "e": 158, "s": 123, "text": "PROGRAMMINGJava ExamplesC Examples" }, { "code": null, "e": 172, "s": 158, "text": "Java Examples" }, { "code": null, "e": 183, "s": 172, "text": "C Examples" }, { "code": null, "e": 195, "s": 183, ...
statvfs() - Unix, Linux System Call
Unix - Home Unix - Getting Started Unix - File Management Unix - Directories Unix - File Permission Unix - Environment Unix - Basic Utilities Unix - Pipes & Filters Unix - Processes Unix - Communication Unix - The vi Editor Unix - What is Shell? Unix - Using Variables Unix - Special Variables Unix - Using Arrays Unix -...
[ { "code": null, "e": 1466, "s": 1454, "text": "Unix - Home" }, { "code": null, "e": 1489, "s": 1466, "text": "Unix - Getting Started" }, { "code": null, "e": 1512, "s": 1489, "text": "Unix - File Management" }, { "code": null, "e": 1531, "s": 1...
K-Means Clustering — Explained. Detailed theorotical explanation and... | by Soner Yıldırım | Towards Data Science
Let’s assume we start a business to sell some services to people. Business goes well and we have about ten thousand customers in our database within a few months. We want to keep our customers and also increase our revenue per customer. So we plan to offer a deal to the customers in our database. We have two options: O...
[ { "code": null, "e": 490, "s": 171, "text": "Let’s assume we start a business to sell some services to people. Business goes well and we have about ten thousand customers in our database within a few months. We want to keep our customers and also increase our revenue per customer. So we plan to offe...
Check whether triangle is valid or not if three points are given - GeeksforGeeks
25 Mar, 2021 Given coordinates of three points in a plane P1, P2 and P3, the task is to check if the three points form a triangle or notExamples: Input: P1 = (1, 5), P2 = (2, 5), P3 = (4, 6) Output: YesInput: P1 = (1, 1), P2 = (1, 4), P3 = (1, 5) Output: No Approach: The key observation in the problem is three po...
[ { "code": null, "e": 26256, "s": 26228, "text": "\n25 Mar, 2021" }, { "code": null, "e": 26391, "s": 26256, "text": "Given coordinates of three points in a plane P1, P2 and P3, the task is to check if the three points form a triangle or notExamples: " }, { "code": null, ...
Maximum of all distances to the nearest 1 cell from any 0 cell in a Binary matrix - GeeksforGeeks
25 Apr, 2022 Given a Matrix of size N*N filled with 1‘s and 0‘s, the task is to find the maximum distance from a 0-cell to its nearest 1-cell. If the matrix is filled with only 0’s or only 1’s, return -1. Note: Only horizontal and vertical movements are allowed in the matrix. Examples: Input: mat[][] = {{0, 1, 0}, ...
[ { "code": null, "e": 25943, "s": 25915, "text": "\n25 Apr, 2022" }, { "code": null, "e": 26135, "s": 25943, "text": "Given a Matrix of size N*N filled with 1‘s and 0‘s, the task is to find the maximum distance from a 0-cell to its nearest 1-cell. If the matrix is filled with only...
Maximum sum such that no two elements are adjacent - GeeksforGeeks
26 Apr, 2022 Given an array arr[] of positive numbers, the task is to find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be adjacent in the array. Examples: Input: arr[] = {5, 5, 10, 100, 10, 5}Output: 110Explanation: Pick the subsequence {5, 100, 5}.The sum is 110 and n...
[ { "code": null, "e": 42521, "s": 42493, "text": "\n26 Apr, 2022" }, { "code": null, "e": 42703, "s": 42521, "text": "Given an array arr[] of positive numbers, the task is to find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be adja...
Dropout in Neural Networks - GeeksforGeeks
16 Jul, 2020 The concept of Neural Networks is inspired by the neurons in the human brain and scientists wanted a machine to replicate the same process. This craved a path to one of the most important topics in Artificial Intelligence. A Neural Network (NN) is based on a collection of connected units or nodes called ar...
[ { "code": null, "e": 25957, "s": 25929, "text": "\n16 Jul, 2020" }, { "code": null, "e": 26604, "s": 25957, "text": "The concept of Neural Networks is inspired by the neurons in the human brain and scientists wanted a machine to replicate the same process. This craved a path to o...
How to install Python on Windows? - GeeksforGeeks
05 Oct, 2021 Prerequisite: Python Language Introduction Before we start with how to install Python3 on Windows, let’s first go through the basic introduction to Python. Python is a widely-used general-purpose, high-level programming language. Python is a programming language that lets you work quickly and integrate sys...
[ { "code": null, "e": 26071, "s": 26043, "text": "\n05 Oct, 2021" }, { "code": null, "e": 26487, "s": 26071, "text": "Prerequisite: Python Language Introduction Before we start with how to install Python3 on Windows, let’s first go through the basic introduction to Python. Python ...
Find Count of Single Valued Subtrees - GeeksforGeeks
28 Apr, 2022 Given a binary tree, write a program to count the number of Single Valued Subtrees. A Single Valued Subtree is one in which all the nodes have same value. Expected time complexity is O(n).Example: Input: root of below tree 5 / \ 1 5 / \ \ 5 ...
[ { "code": null, "e": 26695, "s": 26667, "text": "\n28 Apr, 2022" }, { "code": null, "e": 26893, "s": 26695, "text": "Given a binary tree, write a program to count the number of Single Valued Subtrees. A Single Valued Subtree is one in which all the nodes have same value. Expected...
Multiple Density Plots with Pandas in Python - GeeksforGeeks
03 Jan, 2021 Multiple density plots are a great way of comparing the distribution of multiple groups in your data. We can make multiple density plots using pandas plot.density() function. However, we need to convert data in a wide format if we are using the density function. Wide data represents different groups in di...
[ { "code": null, "e": 25555, "s": 25527, "text": "\n03 Jan, 2021" }, { "code": null, "e": 25943, "s": 25555, "text": "Multiple density plots are a great way of comparing the distribution of multiple groups in your data. We can make multiple density plots using pandas plot.density...
PHP | base64_decode() Function - GeeksforGeeks
08 Jul, 2021 The base64_decode() is an inbuilt function in PHP which is used to Decodes data which is encoded in MIME base64.Syntax: string base64_decode( $data, $strict ) Parameters: This function accepts two parameter as mentioned above and described below: $data: It is mandatory parameter which contains the enco...
[ { "code": null, "e": 26409, "s": 26381, "text": "\n08 Jul, 2021" }, { "code": null, "e": 26531, "s": 26409, "text": "The base64_decode() is an inbuilt function in PHP which is used to Decodes data which is encoded in MIME base64.Syntax: " }, { "code": null, "e": 2657...
Python - Get the indices of Uppercase characters in given string - GeeksforGeeks
02 Sep, 2020 Given a String extract indices of uppercase characters. Input : test_str = ‘GeeKsFoRGeeks’Output : [0, 3, 5, 7, 8]Explanation : Returns indices of uppercase characters. Input : test_str = ‘GFG’Output : [0, 1, 2]Explanation : All are uppercase. Method #1 : Using list comprehension + range() + isupper() In ...
[ { "code": null, "e": 25581, "s": 25553, "text": "\n02 Sep, 2020" }, { "code": null, "e": 25637, "s": 25581, "text": "Given a String extract indices of uppercase characters." }, { "code": null, "e": 25750, "s": 25637, "text": "Input : test_str = ‘GeeKsFoRGeeks’...
Java Program to Print All the Repeated Numbers with Frequency in an Array - GeeksforGeeks
27 Nov, 2020 The frequency of an element in an array is the count of the occurrence of that particular element in the whole array. Given an array that may contain duplicates, print all repeated/duplicate elements and their frequencies. Below is the discussion of this program by two approaches: Using a counter array: By...
[ { "code": null, "e": 26643, "s": 26615, "text": "\n27 Nov, 2020" }, { "code": null, "e": 26866, "s": 26643, "text": "The frequency of an element in an array is the count of the occurrence of that particular element in the whole array. Given an array that may contain duplicates, p...
Optional Class | isPresent() function - GeeksforGeeks
22 Feb, 2018 The isPresent() function in Optional Class is used to evaluate whether the value if assigned to variable is present or not. Syntax value.isPresent() Returns: It returns true if value is assigned otherwise false Examples: Input : Optional value1 = Optional.ofNullable(10); value1.isPresent() Output...
[ { "code": null, "e": 25473, "s": 25445, "text": "\n22 Feb, 2018" }, { "code": null, "e": 25597, "s": 25473, "text": "The isPresent() function in Optional Class is used to evaluate whether the value if assigned to variable is present or not." }, { "code": null, "e": 25...
POSITION() function in MySQL - GeeksforGeeks
04 Dec, 2020 POSITION() : This function in MySQL is used for finding the location of a substring in a string. It will return the location of the first occurrence of the substring in the string. If the substring is not present in the string then it will return 0. When searching for the location of a substring in a stri...
[ { "code": null, "e": 25513, "s": 25485, "text": "\n04 Dec, 2020" }, { "code": null, "e": 25527, "s": 25513, "text": "POSITION() : " }, { "code": null, "e": 25883, "s": 25527, "text": "This function in MySQL is used for finding the location of a substring in a ...
How to Filter DataFrame Rows Based on the Date in Pandas? - GeeksforGeeks
24 Jan, 2021 Filtering a DataFrame rows by date selects all rows which satisfy specified date constraints, based on a column containing date data. For instance, selecting all rows between March 13, 2020, and December 31, 2020, would return all rows with date values in that range. Use DataFrame.loc() with the indexing s...
[ { "code": null, "e": 25537, "s": 25509, "text": "\n24 Jan, 2021" }, { "code": null, "e": 25805, "s": 25537, "text": "Filtering a DataFrame rows by date selects all rows which satisfy specified date constraints, based on a column containing date data. For instance, selecting all r...
Solidity – Variables
11 May, 2022 A Variable is basically a placeholder for the data which can be manipulated at runtime. Variables allow users to retrieve and change the stored information. 1. A variable name should not match with reserved keywords. 2. Variable names must start with a letter or an underscore (_), and may contain letters ...
[ { "code": null, "e": 53, "s": 25, "text": "\n11 May, 2022" }, { "code": null, "e": 211, "s": 53, "text": "A Variable is basically a placeholder for the data which can be manipulated at runtime. Variables allow users to retrieve and change the stored information. " }, { "c...
Minimum number of given operations required to convert a permutation into an identity permutation
26 May, 2021 Given a permutation P (P1, P2, P3, ... Pn) of first n natural numbers. Find the minimum number of operations to convert it into an identity permutation i.e. 1, 2, 3, ..., n where each operation is defined as: P[i] = P[P[P[i]]] i from 1 to n (1 based indexing). If there is no way to convert then print -1.Ex...
[ { "code": null, "e": 52, "s": 24, "text": "\n26 May, 2021" }, { "code": null, "e": 369, "s": 52, "text": "Given a permutation P (P1, P2, P3, ... Pn) of first n natural numbers. Find the minimum number of operations to convert it into an identity permutation i.e. 1, 2, 3, ..., n w...
Java.util Interface Spliterator in Java8
30 May, 2018 Prerequisite : Iterators in java Spliterators, like other Iterators, are for traversing the elements of a source. A source can be a Collection, an IO channel or a generator function. It is included in JDK 8 for support of efficient parallel traversal(parallel programming) in addition to sequential traversa...
[ { "code": null, "e": 54, "s": 26, "text": "\n30 May, 2018" }, { "code": null, "e": 87, "s": 54, "text": "Prerequisite : Iterators in java" }, { "code": null, "e": 237, "s": 87, "text": "Spliterators, like other Iterators, are for traversing the elements of a s...
Python – Unique value keys in a dictionary with lists as values
08 May, 2020 Sometimes, while working with Python dictionaries, we can have problem in which we need to extract keys with values that are unique (there should be at least one item not present in other lists), i.e doesn’t occur in any other key’s value lists. This can have applications in data preprocessing. Lets discus...
[ { "code": null, "e": 28, "s": 0, "text": "\n08 May, 2020" }, { "code": null, "e": 387, "s": 28, "text": "Sometimes, while working with Python dictionaries, we can have problem in which we need to extract keys with values that are unique (there should be at least one item not pres...
Parallel matrix-vector multiplication in NumPy
23 Sep, 2021 In this article, we will discuss how to do matrix-vector multiplication in NumPy. For a matrix-vector multiplication, there are certain important points: The end product of a matrix-vector multiplication is a vector. Each element of this vector is obtained by performing a dot product between each row of th...
[ { "code": null, "e": 28, "s": 0, "text": "\n23 Sep, 2021" }, { "code": null, "e": 110, "s": 28, "text": "In this article, we will discuss how to do matrix-vector multiplication in NumPy." }, { "code": null, "e": 182, "s": 110, "text": "For a matrix-vector mult...
How to serialize an object into a list of URL query parameters using JavaScript ?
28 Jun, 2019 Given a JavaScript Object and the task is to serialize it into a URL query parameters using JavaScript. Approach 1: Declare an object and store it into the variable. Then use JSON.stringify() method to convert javascript object into string and display the content. Next, take an empty string and append (key...
[ { "code": null, "e": 28, "s": 0, "text": "\n28 Jun, 2019" }, { "code": null, "e": 132, "s": 28, "text": "Given a JavaScript Object and the task is to serialize it into a URL query parameters using JavaScript." }, { "code": null, "e": 144, "s": 132, "text": "Ap...
YAML Comments
14 Dec, 2020 YAML_Comments Comments are used to prevent the execution of statements. Comments are ignored while the compiler executes the code. Comments are user-friendly as user can get explanations of code using comments. Since you are alright with the sentence structure and fundamentals of YAML, let us continue furt...
[ { "code": null, "e": 54, "s": 26, "text": "\n14 Dec, 2020" }, { "code": null, "e": 68, "s": 54, "text": "YAML_Comments" }, { "code": null, "e": 265, "s": 68, "text": "Comments are used to prevent the execution of statements. Comments are ignored while the comp...
Seating arrangement of n boys and girls alternatively around a round table
10 May, 2021 There are n boys and n girls are to be seated around a round table, in a circle. The task is to find the number of ways in which n boys and n girls can sit alternatively around a round table. Given n<10Examples: Input: n = 5 Output: 2880 Input: n = 1 Output: 1 Approach: First find the total number ...
[ { "code": null, "e": 54, "s": 26, "text": "\n10 May, 2021" }, { "code": null, "e": 268, "s": 54, "text": "There are n boys and n girls are to be seated around a round table, in a circle. The task is to find the number of ways in which n boys and n girls can sit alternatively arou...
Plot the magnitude spectrum in Python using Matplotlib
21 Apr, 2020 A Signal is an electromagnetic field or an electric current to transmit data. There are various components of a signal such as frequency, amplitude, wavelength, phase, angular frequency and period from which it is described.A periodic signal can be represented using the below sine function: y = A sin(w*t +...
[ { "code": null, "e": 54, "s": 26, "text": "\n21 Apr, 2020" }, { "code": null, "e": 346, "s": 54, "text": "A Signal is an electromagnetic field or an electric current to transmit data. There are various components of a signal such as frequency, amplitude, wavelength, phase, angula...
Python | Display images with PyGame
08 Jan, 2019 Pygame is a cross-platform set of Python modules designed for writing video games. It includes computer graphics and sound libraries designed to be used with the Python programming language. Now, it’s up to the imagination or necessity of developer, what type of game he/she wants to develop using this tool...
[ { "code": null, "e": 54, "s": 26, "text": "\n08 Jan, 2019" }, { "code": null, "e": 366, "s": 54, "text": "Pygame is a cross-platform set of Python modules designed for writing video games. It includes computer graphics and sound libraries designed to be used with the Python progr...
Python - WordNet Interface
WordNet is a dictionary of English, similar to a traditional thesaurus NLTK includes the English WordNet. We can use it as a reference for getting the meaning of words, usage example and definition. A collection of similar words is called lemmas. The words in WordNet are organized and nodes and edges where the nodes re...
[ { "code": null, "e": 3039, "s": 2587, "text": "WordNet is a dictionary of English, similar to a traditional thesaurus NLTK includes the English WordNet. We can use it as a reference for getting the meaning of words, usage example and definition. A collection of similar words is called lemmas. The wo...
Calendar getDisplayName() Method in Java with Examples - GeeksforGeeks
18 Feb, 2019 The getDisplayName(int cal_field, int cal_style, Locale local) method of Calendar class is used to return the string representation of a calendar field(int cal_field) value in the given style(int cal_style) and locale(int local). Syntax: public String getDisplayName(int cal_field, int cal_style, Locale loc...
[ { "code": null, "e": 23557, "s": 23529, "text": "\n18 Feb, 2019" }, { "code": null, "e": 23787, "s": 23557, "text": "The getDisplayName(int cal_field, int cal_style, Locale local) method of Calendar class is used to return the string representation of a calendar field(int cal_fie...
XAML - ContextMenu
A ContextMenu represents a pop-up menu that enables a control to expose a functionality that is specific to the context of a control. It appears whenever the context menu is requested through a user interface from within this element. The hierarchical inheritance of ContextMenu class is as follows − Background Gets or ...
[ { "code": null, "e": 2224, "s": 1923, "text": "A ContextMenu represents a pop-up menu that enables a control to expose a functionality that is specific to the context of a control. It appears whenever the context menu is requested through a user interface from within this element. The hierarchical i...
Add legend for multiple lines in R using ggplot2 - GeeksforGeeks
24 Jun, 2021 In this article, we are going to see how to add legends for multiple line plots in R Programming Language using ggplot2. First, you need to install the ggplot2 package if it is not previously installed in R Studio. The functions used to create the line plots are : geom_line( ) : To plot the line and assig...
[ { "code": null, "e": 25242, "s": 25214, "text": "\n24 Jun, 2021" }, { "code": null, "e": 25458, "s": 25242, "text": " In this article, we are going to see how to add legends for multiple line plots in R Programming Language using ggplot2. First, you need to install the ggplot2 pa...
C# | Dapper - GeeksforGeeks
26 Apr, 2021 To understand Dapper, first, we need to know what is ORM or Object Relational Mapper. Object Relational Mapper(ORM) : Object Relational Mapping is the concept of writing queries using the object-oriented paradigm of the preferred programming language. ORM is used to interact with the SQL databases using o...
[ { "code": null, "e": 24304, "s": 24276, "text": "\n26 Apr, 2021" }, { "code": null, "e": 24391, "s": 24304, "text": "To understand Dapper, first, we need to know what is ORM or Object Relational Mapper. " }, { "code": null, "e": 24754, "s": 24391, "text": "Obj...
C# | Identifiers - GeeksforGeeks
07 Jul, 2021 In programming languages, identifiers are used for identification purposes. Or in other words, identifiers are the user-defined name of the program components. In C#, an identifier can be a class name, method name, variable name or label. Example: public class GFG { static public void Main () { ...
[ { "code": null, "e": 25304, "s": 25276, "text": "\n07 Jul, 2021" }, { "code": null, "e": 25554, "s": 25304, "text": "In programming languages, identifiers are used for identification purposes. Or in other words, identifiers are the user-defined name of the program components. In ...
Erlang - Lists
The List is a structure used to store a collection of data items. In Erlang, Lists are created by enclosing the values in square brackets. Following is a simple example of creating a list of numbers in Erlang. -module(helloworld). -export([start/0]). start() -> Lst1 = [1,2,3], io:fwrite("~w~n",[Lst1]). The o...
[ { "code": null, "e": 2440, "s": 2301, "text": "The List is a structure used to store a collection of data items. In Erlang, Lists are created by enclosing the values in square brackets." }, { "code": null, "e": 2511, "s": 2440, "text": "Following is a simple example of creating a...
Zend Framework - Models & Database
In this chapter, we will discuss regarding the various models and the database of the Zend Framework. A Model defines the logical data representation of the application. For example, in a shopping cart application – Product, Customer, Cart and Orders are models. They define the properties of the entity it holds. Some o...
[ { "code": null, "e": 2414, "s": 2312, "text": "In this chapter, we will discuss regarding the various models and the database of the Zend Framework." }, { "code": null, "e": 2674, "s": 2414, "text": "A Model defines the logical data representation of the application. For example,...
How to convert a String to an enum in Java?
The valueOf() method of the Enum class in java accepts a String value and returns an enum constant of the specified type. Let us create an enum with name Vehicles with 5 constants representing models of 5 different scoters with their prices as values, as shown below − enum Vehicles { //Constants with values ACTIV...
[ { "code": null, "e": 1184, "s": 1062, "text": "The valueOf() method of the Enum class in java accepts a String value and returns an enum constant of the specified type." }, { "code": null, "e": 1331, "s": 1184, "text": "Let us create an enum with name Vehicles with 5 constants re...
AngularJS | API - GeeksforGeeks
30 Apr, 2019 AngularJS APIs are used for comparing, iterating and converting objects.Basic AngularJS API includes angular.isString() angular.lowercase() angular.uppercase() angular.isNumber() 1. angular.isString()It is used to check whether an object is a string or not.It returns true if the object is string otherwise ...
[ { "code": null, "e": 28271, "s": 28243, "text": "\n30 Apr, 2019" }, { "code": null, "e": 28372, "s": 28271, "text": "AngularJS APIs are used for comparing, iterating and converting objects.Basic AngularJS API includes" }, { "code": null, "e": 28391, "s": 28372, ...
How to blur an image using Node Jimp blur() function?
NodeJS – Blur() is an inbuilt function that is used to blur images. The effect produced by JIMP blur() will be similar to that of the Gaussian blur. It blurs based on the pixels input. blur(r, cb) r – It takes the input for blur and blurs based upon the pixels. If r is 2, it will blur 2 pixels at a time. r – It takes t...
[ { "code": null, "e": 1247, "s": 1062, "text": "NodeJS – Blur() is an inbuilt function that is used to blur images. The effect produced by JIMP blur() will be similar to that of the Gaussian blur. It blurs based on the pixels input." }, { "code": null, "e": 1259, "s": 1247, "text"...
Python - Edit objects inside tuple - GeeksforGeeks
03 Jun, 2020 Sometimes, while working with tuples, being immutable, can offer a lot of confusion regarding its working. One of the questions that can pop from mind is, that Are objects inside tuples mutable?. The answer to this is Yes. Let’s discuss certain ways in which this can be achieved. Method #1 : Using Access m...
[ { "code": null, "e": 24237, "s": 24209, "text": "\n03 Jun, 2020" }, { "code": null, "e": 24518, "s": 24237, "text": "Sometimes, while working with tuples, being immutable, can offer a lot of confusion regarding its working. One of the questions that can pop from mind is, that Are...
Maximum Path Sum in a Binary Tree in C++
In this problem, we are given a binary tree with each node containing a value. Our task is to create a program to find the maximum path sum between two leaves of a binary tree. Here, we have to find the path form one leaf node to another leaf node that will provide the maximum sum of values. This maximum sum path can/c...
[ { "code": null, "e": 1239, "s": 1062, "text": "In this problem, we are given a binary tree with each node containing a value. Our task is to create a program to find the maximum path sum between two leaves of a binary tree." }, { "code": null, "e": 1411, "s": 1239, "text": "Here,...
C++ Program to Check Whether a Number is Prime or Not
A prime number is a whole number that is greater than one and the only factors of a prime number should be one and itself. Some of the first prime numbers are − 2, 3, 5, 7, 11, 13 ,17 The program to check if a number is prime or not is as follows. Live Demo #include <iostream> using namespace std; int main() { int ...
[ { "code": null, "e": 1223, "s": 1062, "text": "A prime number is a whole number that is greater than one and the only factors of a prime number should be one and itself. Some of the first prime numbers are −" }, { "code": null, "e": 1246, "s": 1223, "text": "2, 3, 5, 7, 11, 13 ,1...
Matplotlib.pyplot.autoscale() in Python - GeeksforGeeks
23 Jun, 2020 Matplotlib is a widely used library in Python for plotting various graphs, as it provides very efficient ways and easy to understand methods for complex plots also. matplotlib.pyplot is a plotting library used for 2D graphics in Python programming language. Pyplot is a collection of command style functions...
[ { "code": null, "e": 24876, "s": 24848, "text": "\n23 Jun, 2020" }, { "code": null, "e": 25223, "s": 24876, "text": "Matplotlib is a widely used library in Python for plotting various graphs, as it provides very efficient ways and easy to understand methods for complex plots also...
A Tell of Tensorflow Probability. Regardless of whatever we think about... | by Shubhadeep Roychowdhury | Towards Data Science
Regardless of whatever we think about the mysterious subject of Probability, we live and breath in a stochastic environment. From the ever elusive Quantum Mechanics to our daily life (“There is 70% chance it will rain today”, “The chance of getting the job done in time is less than 30%” ... ) we use it, knowingly or un...
[ { "code": null, "e": 654, "s": 171, "text": "Regardless of whatever we think about the mysterious subject of Probability, we live and breath in a stochastic environment. From the ever elusive Quantum Mechanics to our daily life (“There is 70% chance it will rain today”, “The chance of getting the jo...
Ropes Data Structure (Fast String Concatenation) - GeeksforGeeks
02 Jul, 2021 One of the most common operations on strings is appending or concatenation. Appending to the end of a string when the string is stored in the traditional manner (i.e. an array of characters) would take a minimum of O(n) time (where n is the length of the original string). We can reduce time taken by append...
[ { "code": null, "e": 26657, "s": 26629, "text": "\n02 Jul, 2021" }, { "code": null, "e": 26995, "s": 26657, "text": "One of the most common operations on strings is appending or concatenation. Appending to the end of a string when the string is stored in the traditional manner (i...
Smallest and Largest sum of two n-digit numbers - GeeksforGeeks
26 Mar, 2021 Given an integer N ≥ 1, the task is to find the smallest and the largest sum of two N digit numbers.Examples: Input: N = 1 Output: Largest = 18 Smallest = 0 Largest 1-digit number is 9 and 9 + 9 = 18 Smallest 1-digit number is 0 and 0 + 0 = 0Input: N = 2 Output: Largest = 198 Smallest = 20 Approach: ...
[ { "code": null, "e": 26047, "s": 26019, "text": "\n26 Mar, 2021" }, { "code": null, "e": 26159, "s": 26047, "text": "Given an integer N ≥ 1, the task is to find the smallest and the largest sum of two N digit numbers.Examples: " }, { "code": null, "e": 26342, "s"...
Fast Transition Between dplyr and data.table | by Nata Berishvili | Nov, 2020 | Towards Data Science | Towards Data Science
In this post, I compare the syntax of R’s two most powerful data manipulation libraries: dplyr and data.table. I am not here to advocate any package. However, while working on a project with unusually large datasets, my preferred package became data.table, for speed and memory efficiency. I took a legacy project in dpl...
[ { "code": null, "e": 625, "s": 171, "text": "In this post, I compare the syntax of R’s two most powerful data manipulation libraries: dplyr and data.table. I am not here to advocate any package. However, while working on a project with unusually large datasets, my preferred package became data.table...
Python - Poisson Distribution
A Poisson distribution is a distribution which shows the likely number of times that an event will occur within a pre-determined period of time. It is used for independent events which occur at a constant rate within a given interval of time. The Poisson distribution is a discrete function, meaning that the event can o...
[ { "code": null, "e": 2959, "s": 2529, "text": "A Poisson distribution is a distribution which shows the likely number of times that an event will occur within a pre-determined period of time. It is used for independent events which occur at a constant rate within a given interval of time. The Poisso...
Check if two unsorted arrays (with duplicates allowed) have same elements - GeeksforGeeks
21 May, 2021 Given two unsorted arrays, check whether both arrays have the same set of elements or not. Examples: Input : A = {2, 5, 6, 8, 10, 2, 2} B = {2, 5, 5, 6, 8, 5, 6} Output : No Input : A = {2, 5, 6, 8, 2, 10, 2} B = {2, 5, 6, 8, 2, 10, 2} Output : Yes Input : A = {2, 5, 8, 6, 10, 2, 2} ...
[ { "code": null, "e": 24281, "s": 24253, "text": "\n21 May, 2021" }, { "code": null, "e": 24373, "s": 24281, "text": "Given two unsorted arrays, check whether both arrays have the same set of elements or not. " }, { "code": null, "e": 24384, "s": 24373, "text":...
Compiler Design - Code Generation
Code generation can be considered as the final phase of compilation. Through post code generation, optimization process can be applied on the code, but that can be seen as a part of code generation phase itself. The code generated by the compiler is an object code of some lower-level programming language, for example, ...
[ { "code": null, "e": 2739, "s": 2193, "text": "Code generation can be considered as the final phase of compilation. Through post code generation, optimization process can be applied on the code, but that can be seen as a part of code generation phase itself. The code generated by the compiler is an ...
Find orientation of a pattern in a matrix - GeeksforGeeks
02 Mar, 2022 Given a matrix of characters and a pattern, find the orientation of pattern in the matrix. In other words, find if pattern appears in matrix in horizontal or vertical direction. Achieve this in minimum time possible. Input: mat[N][N] = { {'a', 'b', 'c', 'd', 'e'}, {'f', 'g', 'h', 'i', 'j'}, ...
[ { "code": null, "e": 24816, "s": 24788, "text": "\n02 Mar, 2022" }, { "code": null, "e": 25033, "s": 24816, "text": "Given a matrix of characters and a pattern, find the orientation of pattern in the matrix. In other words, find if pattern appears in matrix in horizontal or verti...
Python implementation of automatic Tic Tac Toe game using random number
21 Aug, 2020 Tic-tac-toe is a very popular game, so let’s implement an automatic Tic-tac-toe game using Python. The game is automatically played by the program and hence, no user input is needed. Still, developing a automatic game will be lots of fun. Let’s see how to do this. numpy and random Python libraries are used...
[ { "code": null, "e": 54, "s": 26, "text": "\n21 Aug, 2020" }, { "code": null, "e": 153, "s": 54, "text": "Tic-tac-toe is a very popular game, so let’s implement an automatic Tic-tac-toe game using Python." }, { "code": null, "e": 319, "s": 153, "text": "The ga...
Python Dictionary popitem() method
04 Oct, 2021 Python dictionary popitem() method removes the last inserted key-value pair from the dictionary and returns it as a tuple. Syntax : dict.popitem() Parameters : None Returns : A tuple containing the arbitrary key-value pair from dictionary. That pair is removed from dictionary. Generating a random number...
[ { "code": null, "e": 52, "s": 24, "text": "\n04 Oct, 2021" }, { "code": null, "e": 175, "s": 52, "text": "Python dictionary popitem() method removes the last inserted key-value pair from the dictionary and returns it as a tuple." }, { "code": null, "e": 200, "s": ...
Time Complexity of a Loop when Loop variable “Expands or Shrinks” exponentially
08 May, 2019 For such cases, time complexity of the loop is O(log(log(n))).The following cases analyse different aspects of the problem. Case 1 : for (int i = 2; i <=n; i = pow(i, k)) { // some O(1) expressions or statements} In this case, i takes values 2, 2k, (2k)k = 2k2, (2k2)k = 2k3, ..., 2klogk(log(n)). The la...
[ { "code": null, "e": 54, "s": 26, "text": "\n08 May, 2019" }, { "code": null, "e": 178, "s": 54, "text": "For such cases, time complexity of the loop is O(log(log(n))).The following cases analyse different aspects of the problem." }, { "code": null, "e": 187, "s":...
Type Systems:Dynamic Typing, Static Typing & Duck Typing
17 Mar, 2019 In Dynamic Typing, type checking is performed at runtime. For example, Python is a dynamically typed language. It means that the type of a variable is allowed to change over its lifetime. Other dynamically typed languages are -Perl, Ruby, PHP, Javascript etc.Let’s take a Python code example to see if a var...
[ { "code": null, "e": 53, "s": 25, "text": "\n17 Mar, 2019" }, { "code": null, "e": 383, "s": 53, "text": "In Dynamic Typing, type checking is performed at runtime. For example, Python is a dynamically typed language. It means that the type of a variable is allowed to change over ...
Number of paths with exactly k coins
28 Jun, 2022 Given a matrix where every cell has some number of coins. Count number of ways to reach bottom right from top left with exactly k coins. We can move to (i+1, j) and (i, j+1) from a cell (i, j). Example: Input: k = 12 mat[][] = { {1, 2, 3}, {4, 6, 5}, {3, 2,...
[ { "code": null, "e": 52, "s": 24, "text": "\n28 Jun, 2022" }, { "code": null, "e": 246, "s": 52, "text": "Given a matrix where every cell has some number of coins. Count number of ways to reach bottom right from top left with exactly k coins. We can move to (i+1, j) and (i, j+1) ...
Java Hello World Program
22 Jun, 2022 Java is one of the most popular and widely used programming languages and platforms. Java is fast, reliable, and secure. Java is used in every nook and corner from desktop to web applications, scientific supercomputers to gaming consoles, cell phones to the Internet. Java is easy to learn, and its syntax i...
[ { "code": null, "e": 53, "s": 25, "text": "\n22 Jun, 2022" }, { "code": null, "e": 321, "s": 53, "text": "Java is one of the most popular and widely used programming languages and platforms. Java is fast, reliable, and secure. Java is used in every nook and corner from desktop to...
How to match parentheses in Python regular expression?
The following code matches parentheses in the string s and then removes the parentheses in string s1 using Python regular expression. import re s = 'I love book()' result = re.search(r'\(\)',s) print result.group() s1 = 'I love book(s)' result2 = re.sub(r'[\(\)]','',s1) print result2 This gives the output () I love bo...
[ { "code": null, "e": 1322, "s": 1187, "text": "The following code matches parentheses in the string s and then removes the parentheses in string s1 using Python regular expression." }, { "code": null, "e": 1473, "s": 1322, "text": "import re\ns = 'I love book()'\nresult = re.sea...
Python unittest – assertIsInstance() function
29 Aug, 2020 assertIsInstance() in Python is a unittest library function that is used in unit testing to check whether an object is an instance of a given class or not. This function will take three parameters as input and return a boolean value depending upon the assert condition. If the object is an instance ofthe gi...
[ { "code": null, "e": 28, "s": 0, "text": "\n29 Aug, 2020" }, { "code": null, "e": 388, "s": 28, "text": "assertIsInstance() in Python is a unittest library function that is used in unit testing to check whether an object is an instance of a given class or not. This function will ...
Number of palindromic permutations | Set 1
03 May, 2021 Given string str, find count of all palindromic permutations of it.Examples : Input : str = "gfgf" Output : 2 There are two palindromic permutations fggf and gffg Input : str = "abc" Output : 0 The idea is based on below facts : A string can permute to a palindrome if number of odd occurring charac...
[ { "code": null, "e": 52, "s": 24, "text": "\n03 May, 2021" }, { "code": null, "e": 132, "s": 52, "text": "Given string str, find count of all palindromic permutations of it.Examples : " }, { "code": null, "e": 250, "s": 132, "text": "Input : str = \"gfgf\"\nO...
Implementation of Grey Wolf Optimization (GWO) Algorithm
27 Feb, 2022 Previous article Grey wolf optimization- Introduction talked about inspiration of grey wolf optimization, and its mathematical modelling and algorithm. In this article we will implement grey wolf optimization (PSO) for two fitness functions – Rastrigin function and Sphere function. The aim of Grey wolf opt...
[ { "code": null, "e": 28, "s": 0, "text": "\n27 Feb, 2022" }, { "code": null, "e": 396, "s": 28, "text": "Previous article Grey wolf optimization- Introduction talked about inspiration of grey wolf optimization, and its mathematical modelling and algorithm. In this article we will...
Introduction to Merkle Tree
02 Feb, 2022 Merkle tree also known as hash tree is a data structure used for data verification and synchronization. It is a tree data structure where each non-leaf node is a hash of it’s child nodes. All the leaf nodes are at the same depth and are as far left as possible. It maintains data integrity and uses hash fun...
[ { "code": null, "e": 54, "s": 26, "text": "\n02 Feb, 2022" }, { "code": null, "e": 726, "s": 54, "text": "Merkle tree also known as hash tree is a data structure used for data verification and synchronization. It is a tree data structure where each non-leaf node is a hash of it’s...
GATE | GATE-CS-2003 | Question 61
28 Jun, 2021 In a permutation a1.....an of n distinct integers, an inversion is a pair (ai, aj) such that i aj. If all permutations are equally likely, what is the expected number of inversions in a randomly chosen permutation of 1.....n ?(A) n(n – 1)/2 (B) n(n – 1)/4(C) n(n + 1)/4(D) 2n[log2 n]Answer: (B)Explanation: ...
[ { "code": null, "e": 52, "s": 24, "text": "\n28 Jun, 2021" }, { "code": null, "e": 293, "s": 52, "text": "In a permutation a1.....an of n distinct integers, an inversion is a pair (ai, aj) such that i aj. If all permutations are equally likely, what is the expected number of inve...