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
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/
Python str.isdigit() and its application

Python provides several string methods such as str.capitalize(),str.count(), str.encode(), str.find() etc. One such string method is str.isdigit(). str.isdigit() - Syntax: your_string.isdigit() Parameters: Doesn’t take any. Returns – It returns True if all the characters in the string your_string are digits with a condition that the string should not be empty. If all the conditions are…

https://thecodingbot.com/python-str-isdigit-and-its-application/
Python ord() function and its application

In Python, ord() is a built-in function which returns an integer representing the Unicode point value of a character. Before discussing about ord() method, it is important to know what a Unicode encoding is. Unicode: Unicode is the encoding type or standard which contains the character set of all the languages that exist, all around…

https://thecodingbot.com/python-ord-function-and-its-application/
Python abs() and its applications

Python provides many built-in functions, some falls in the category of essential built-in functions while other falls in Non-essential built-in functions. One such essential built-in function is abs(). In this article, we will talk about abs() and its application. abs(x) : abs(x) is a built-in function which returns the absolute value of a number. Syntax:…

https://thecodingbot.com/python-abs-and-its-applications/
Complex number representation in Python

A complex number is a combination of a real and imaginary number in the form x+iy. Here, x and y are the real numbers, and the i is called the “unit imaginary number” or iota. It is the solution to the equation, . There exist two ways to represent a complex number in mathematics: Rectangular…

https://thecodingbot.com/complex-number-representation-in-python/
std::min_element() in C++ STL

std::min_element() is a utility function under library in C++ STL. The purpose of the function is to give the minimum element value of a container(vector, array etc) within a given range [start, end). Now, the question arises, when we have the std::min(), what is the point of the std::min_element() ? The answer is, there…

https://thecodingbot.com/stdmin_element-in-c-stl/
How to get Unicode code of a character in Python

What is a Unicode encoding? Unicode is the encoding type or standard which contains the character set of all the languages that exist, all around the world. Each character is mapped to an integer known as a Code point. It uniquely identifies a character among the other characters.  The Unicode encoding came into existence when languages other…

https://thecodingbot.com/how-to-get-unicode-code-of-a-character-in-python/
Python’s built-in bin() method with examples

Among many highly useful built-in functions, bin() is also one of them. It was added in Python 2.6, and since then its support has not been deprecated or removed. It is similar to the hex() method which returns the hexadecimal form of the integer while this returns the binary form. bin(x): bin(x) returns the binary…

https://thecodingbot.com/pythons-built-in-bin-method-with-examples/
Convert a binary number(base 2) to the integer(base 10) in Python

Python has hundreds of utility functions that are built-in which ease our efforts to a great extent. Today, the problem we have in hand “Conversion of a binary number to its integer form(base 10)“, python has some built-in methods for this as well. In this article, we will go through different ways we can convert…

https://thecodingbot.com/convert-a-binary-numberbase-2-to-the-integerbase-10-in-python/
Python’s built-in hex() method with examples

In this tutorial, we will talk about hex(), another very useful Python utility method. It is pretty similar to bin(), the latter is used to find the binary representation of an integer, while the former converts the integer to its hexadecimal string format. We talked about built-in bin() function here. Have a read. hex(x): Syntax:…

https://thecodingbot.com/pythons-built-in-hex-method-with-examples/
Python’s built-in dict() method with examples

What is a dictionary in Python? A dictionary is a collection which is unordered, mutable and indexed. Mutable here means the values can be changed after it is initialized. It is basically a set of key:value pairs with a condition that no two keys are same. dict() is a built-in method and also a constructor…

https://thecodingbot.com/pythons-built-in-dict-method-with-examples/
Remove duplicate rows from a Pandas Dataframe

Problem Statement: Given a Pandas dataframe, remove the duplicate rows. Solution: There are certain functions available to remove duplicates or identify duplicated in the dataframe in Pandas. One such function is df.duplicated() and the other function is df.drop_duplicates(). df.duplicated() not exactly removes duplicates from the dataframe but it identifies them. It returns a boolean series,…

https://thecodingbot.com/remove-duplicate-rows-from-a-pandas-dataframe/
How to find the digital root of a non-negative integer

Problem Statement: Given a non-negative integer find it’s digital root (repeated digital sum). Example: DigitalRoot(1335) = 1 + 3 + 3 + 5 = 12 = 1 + 2 = 3. Solution: Before moving forward with the approaches, let’s us see what digital root is. Digital Root (or Repeated Digital Sum):  It is a single digit value obtained…

https://thecodingbot.com/how-to-find-the-digital-root-of-a-non-negative-integer/
IPython/Jupyter notebook keyboard shortcuts

Table of Content: OverviewDifferent Types of mode in Jupyter NotebookCommand Mode shortcutsEdit Mode shortcutsCommon shortcuts Jupyter notebooks(previously known as Ipython Notebook) is an opensource interactive web application that allows us to write and run python codes and also create visualization, equations and markdowns. It is one of the most popular tools used in data analysis…

https://thecodingbot.com/ipython-jupyter-notebook-keyboard-shortcuts/
Python’s built-in bool() with examples

Python provides many built-in functions/methods which ease many cumbersome tasks. One such method is bool(). In this article, we will talk about bool(), its syntax, what parameters it takes and some examples demonstrating its use. bool(x) bool(x) converts the object, x, to a boolean value. What value it will return, True or False, totally depends…

https://thecodingbot.com/pythons-built-in-bool-with-examples/
Different type of looping in Python

Table of Content: OverviewWhile loopDescriptionSyntax and ExamplesBreak statementContinue statementElse statementFor looprange()range(x)range(start,end)range(start,end,step)xrange()Difference between xrange() and range() In programming, a loop is a sequence of instructions that are continuously repeated until certain condition(s) is(are) met. The condition is often known as the terminating condition. In python, the Loops are broadly classified into two types – For loop…

https://thecodingbot.com/different-type-of-looping-in-python/
Python’s built-in all() method with examples

The Python interpreter has a number of functions and types built into it that are always available. One such method is all(). In this tutorial, we will talk about all() – its syntax, what parameter it takes, what is returns and some examples demonstrating its use. all() all(x) returns True if all elements of the iterable are…

https://thecodingbot.com/pythons-built-in-all-method-with-examples/
Python’s built-in any() method with examples

Table of Content: OverviewSyntax and description Examples using any()Time Complexity of the function Python interpreter has a bunch of methods and types built into it. The methods are known as built-in methods. any() is one such method and in a way, you can say it is the sister method of all(). In this tutorial, we…

https://thecodingbot.com/pythons-built-in-any-method-with-examples/
Deleting a linked list in C++

Problem Statement: Given a linked list, write a program to delete it. Example: Linked List: 2->4->6->9 *After Deletion* Output: The Linked List is Empty. Before moving forward, it is necessary to clarify what we actually mean by deletion of the linked list. Deletion of the linked list is not simply pointing the head of the…

https://thecodingbot.com/deleting-a-linked-list-in-c/