Find the largest and the smallest element of a Vector
Problem Statement: Given a vector, find the largest and the smallest value of it. Solution : Example: Input: {1,22,42,5,55,-21,43} Output: Minimum = -21 , Maximum = 55 Input: {88,77,22,44,11,-121,92} Output: Minimum : -121, Maximum : 92 This problem can be solved easily using C++’s Standard Template Library. C++'s STL: The C++ STL (Standard Template Library)…
https://thecodingbot.com/find-the-largest-and-the-smallest-element-of-a-vector/
Problem Statement: Given a vector, find the largest and the smallest value of it. Solution : Example: Input: {1,22,42,5,55,-21,43} Output: Minimum = -21 , Maximum = 55 Input: {88,77,22,44,11,-121,92} Output: Minimum : -121, Maximum : 92 This problem can be solved easily using C++’s Standard Template Library. C++'s STL: The C++ STL (Standard Template Library)…
https://thecodingbot.com/find-the-largest-and-the-smallest-element-of-a-vector/
The Coding Bot
Find the largest and the smallest element of a Vector - The Coding Bot
Problem Statement: Given a vector, find the largest and the smallest value of it. Solution : Example: Input: {1,22,42,5,55,-21,43}Output: Minimum = -21 , Maximum = 55Input: {88,77,22,44,11,-121,92}Output: Minimum : -121, Maximum : 92 This problem can be solved…
std::max_element() in C++ STL
std::max_element() is a utility function under header in C++ STL. The purpose of the function is to give the maximum element value of a container(vector, array etc) within a given range [start, end). Now, the question arises, when we have the std::max(), what is the point of the std::max_element() ? The answer is, there…
https://thecodingbot.com/stdmax_element-in-c-stl/
std::max_element() is a utility function under header in C++ STL. The purpose of the function is to give the maximum element value of a container(vector, array etc) within a given range [start, end). Now, the question arises, when we have the std::max(), what is the point of the std::max_element() ? The answer is, there…
https://thecodingbot.com/stdmax_element-in-c-stl/
The Coding Bot
std::max_element() in C++ STL - The Coding Bot
std::max_element() is a utility function under header in C++ STL. The purpose of the function is to give the maximum element value of a container(vector, array etc) within a given range [start, end). Now, the question arises, when we have the std::max()…
Delete the entire row if any column has NaN
Problem Statement: Given a dataframe, delete all the rows if any column has a NaN value. Solution : The first approach uses Dataframe.dropna() method and the solution is pretty elegant and relatively easy. However, the second solution is not so straightforward, also not recommended as it is SLOW. Approach 1: Using Dataframe.dropna() Dataframe.dropna() provides easy…
https://thecodingbot.com/delete-the-entire-row-if-any-column-has-nan/
Problem Statement: Given a dataframe, delete all the rows if any column has a NaN value. Solution : The first approach uses Dataframe.dropna() method and the solution is pretty elegant and relatively easy. However, the second solution is not so straightforward, also not recommended as it is SLOW. Approach 1: Using Dataframe.dropna() Dataframe.dropna() provides easy…
https://thecodingbot.com/delete-the-entire-row-if-any-column-has-nan/
The Coding Bot
Delete the entire row if any column has NaN - The Coding Bot
Problem Statement: Given a dataframe, delete all the rows if any column has a NaN value. Solution : The first approach uses Dataframe.dropna() method and the solution is pretty elegant and relatively easy. However, the second solution is not so straightforward…
Merge two text columns into a single column in a Pandas Dataframe
There are times when you are doing feature engineering for a data science project and you need to form a new feature by combining two text columns. For example, you are given a dataset with people’s information residing in a city. The columns in the dataset are – First Name, Last Name, Salary, Social Security…
https://thecodingbot.com/merge-two-text-columns-into-a-single-column-in-a-pandas-dataframe/
There are times when you are doing feature engineering for a data science project and you need to form a new feature by combining two text columns. For example, you are given a dataset with people’s information residing in a city. The columns in the dataset are – First Name, Last Name, Salary, Social Security…
https://thecodingbot.com/merge-two-text-columns-into-a-single-column-in-a-pandas-dataframe/
The Coding Bot
Merge two text columns into a single column in a Pandas Dataframe - The Coding Bot
There are times when you are doing feature engineering for a data science project and you need to form a new feature by combining two text columns. For example, you are given a dataset with people’s information residing in a city. The columns in the dataset…
Markdown in Jupyter/Ipython notebook cheatsheet
It makes a huge difference if you present your data science work with clean code, amazing graphs and Markdowns(WoW) !!! We often get so indulge in getting things done that we forget about the representation. Markdowns in Jupyter notebooks beautify them and also improves the readability of the code. Remember to add graphs and plots…
https://thecodingbot.com/markdown-in-jupyter-ipython-notebook-cheatsheet/
It makes a huge difference if you present your data science work with clean code, amazing graphs and Markdowns(WoW) !!! We often get so indulge in getting things done that we forget about the representation. Markdowns in Jupyter notebooks beautify them and also improves the readability of the code. Remember to add graphs and plots…
https://thecodingbot.com/markdown-in-jupyter-ipython-notebook-cheatsheet/
A Quick Guide on IPython(Jupyter) Magic Commands
In addition to the normal python syntax, Jupyter(Ipython) has some more enhancements. These are known in Jupyter(Ipython) as the magic commands, and starts with a prefix character %. These commands provide various utility operations, makes the common tasks easy. There are two types of magic commands: Line Magic : Denoted by %(single percent sign). These…
https://thecodingbot.com/a-quick-guide-for-ipythonjupyter-magic-cells/
In addition to the normal python syntax, Jupyter(Ipython) has some more enhancements. These are known in Jupyter(Ipython) as the magic commands, and starts with a prefix character %. These commands provide various utility operations, makes the common tasks easy. There are two types of magic commands: Line Magic : Denoted by %(single percent sign). These…
https://thecodingbot.com/a-quick-guide-for-ipythonjupyter-magic-cells/
The Coding Bot
A Quick Guide on IPython(Jupyter) Magic Commands - The Coding Bot
In addition to the normal python syntax, Jupyter(Ipython) has some more enhancements. These are known in Jupyter(Ipython) as the magic commands, and starts with a prefix character %. These commands provide various utility operations, makes the common tasks…
Rearrange a linked list such that all even index nodes come after all odd index nodes
Problem Statement: Given a singly linked list, group all odd nodes together followed by all the even nodes. Please note here we are talking about the node number and not the value in the nodes. The program should run in O(1) space complexity and O(nodes) time complexity. Solution: It’s a classic interview problem and pretty…
https://thecodingbot.com/rearrange-a-linked-list-such-that-all-even-index-nodes-come-after-all-odd-index-nodes/
Problem Statement: Given a singly linked list, group all odd nodes together followed by all the even nodes. Please note here we are talking about the node number and not the value in the nodes. The program should run in O(1) space complexity and O(nodes) time complexity. Solution: It’s a classic interview problem and pretty…
https://thecodingbot.com/rearrange-a-linked-list-such-that-all-even-index-nodes-come-after-all-odd-index-nodes/
The Coding Bot
Rearrange a linked list such that all even index nodes come after all odd index nodes - The Coding Bot
In this tutorial, we will see diffferent approached to rearrange a linked list such that all even index nodes come after all odd index nodes.
Print all the ancestors of a node in a Binary Tree
Problem Statement: Given a binary tree print all the ancestors of a node. Example: For the below tree, Ancestors of node 14 are 11,12 and 10. The ancestor of 12 is 10. The ancestors of 11 are 12 and 10. The ancestors of 13 are 12 and 10. The ancestors of 9 are 8 and…
https://thecodingbot.com/print-all-the-ancestors-of-a-node-in-a-binary-tree/
Problem Statement: Given a binary tree print all the ancestors of a node. Example: For the below tree, Ancestors of node 14 are 11,12 and 10. The ancestor of 12 is 10. The ancestors of 11 are 12 and 10. The ancestors of 13 are 12 and 10. The ancestors of 9 are 8 and…
https://thecodingbot.com/print-all-the-ancestors-of-a-node-in-a-binary-tree/
The Coding Bot
The Coding Bot - Print all the ancestors of a node in a Binary Tree
Given a binary tree print all the ancestors of a node. The ancestor of a node: A node that is connected to all lower-level nodes is called an "ancestor". The connected lower-level nodes are "descendants" of the ancestor node.
