Computer Programming
440 subscribers
6 files
231 links
We mainly post about Tech Interview Prep, Machine Learning, Full Stack, Data Structures, Algorithms & Programming Languages.

Please check the pinned message and invite your friends to this channel. Sharing is Caring đź’•
Download Telegram
Channel created
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/
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/
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/
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/
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/
Channel photo updated
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/
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/
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/
Given a binary tree find the node at the deepest level

Problem Statement: Given a binary tree, find the node at the deepest level. If there are more than one nodes at the last level, return any of them. Solution: This problem can be solved both recursively and iteratively(using level order traversal). It is a classic interview question and often asked in many telephonic and round-1 interviews. Just…

https://thecodingbot.com/given-a-binary-tree-find-the-node-at-the-deepest-level/
Check if two binary trees are a mirror image of each other

Problem Statement: Given two binary trees, find if they are a mirror image of each other. Solution: Example : The below two trees are mirror image to each other. Two trees mirror image of each other Two trees are said to be a mirror image of each other when the following criteria satisfy: Root Node…

https://thecodingbot.com/check-if-two-binary-trees-are-a-mirror-image-of-each-other/
Extract digits from a string in Python

Problem Statement: Given a string, extract all the digits from it. Solution: Imagine a scenario where you have a string of names and salaries of persons in the form, “Adam 200 Mathew 300 Brian 1000 Elon 3333“. From the given string, you need to separate only the salaries of all the person to perform some…

https://thecodingbot.com/extract-digits-from-a-string-in-python/