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
Python’s list remove() method with examples

Overview What are the built-in functions in Python? Built-in methods are the utility methods provided by the Python interpreter for our use, and they come along when you install Python in your environment. It help us to skip implementing many common operations like converting an integer to binary form(using bin()), getting Unicode code point(using ord()), getting the…

https://thecodingbot.com/pythons-list-remove-method-with-examples/
Python’s list remove() time and space complexity analysis

Overview We have already discussed the list’s remove() method in great detail here. This tutorial shall only focus on the time and space complexity analysis of the method. Before discussing the time and space complexities, let’s quickly recall what this method is all about. list.remove() list.remove(x) deletes the first occurrence of element x from the list. If the…

https://thecodingbot.com/pythons-list-remove-time-and-space-complexity-analysis/
Swap every ith element of the array with the (i+2)th element

Problem Statement Given an array of positive integers of size N, the task is to swap every ith element with the (i+2)th element of the array Solution The idea is simple, iterate the array and repeat the swapping of ith element with (i+2)th element for every index in the range. For iteration, we can use…

https://thecodingbot.com/swap-every-ith-element-of-the-array-with-the-i2th-element/
Python’s list clear() method with examples

Overview What are the built-in functions in Python? Built-in methods are the utility methods provided by the Python interpreter for our use, and they come along when you install Python in your environment. It helps us to skip the implementation of many common operations like conversion of an integer to binary form(using bin()), getting Unicode code…

https://thecodingbot.com/pythons-list-clear-method-with-examples/
Swap adjacent elements of an array

Problem Statement Given an array of integers of size N, the task is to swap adjacent elements. Solution This problem is very similar to Swap every ith element of the array with the (i+2)th element, and the solutions are also going to be pretty similar. The idea is simple, iterate the array and repeat the swapping…

https://thecodingbot.com/swap-adjacent-elements-of-an-array/
Given a binary tree, find the node with maximum(or minimum) value

Problem Statement Given a binary tree, find the node with maximum(or minimum) value. Solution There exist a general approach to solve these kinds of problems where we have to find some property(maximum, minimum or height of the binary tree). It is clear that for us to find the node with the maximum or minimum value,…

https://thecodingbot.com/given-a-binary-tree-find-the-node-with-maximumor-minimum-value/
Given a binary tree, find it’s Maximum Depth(or height)

Problem Statement Given a binary tree, find it’s maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Note: A leaf is a node with no children. Example :              13             /…

https://thecodingbot.com/given-a-binary-tree-find-its-maximum-depthor-height/
Printing complete star triangle in C++

Problem Statement Given the number of rows, form a complete triangle made up of stars(asterisks) “*”. For Example Input: 5 Output: Complete star triangle pattern in C++ Solution This is an easy problem which can be solved simply using nested loops. Let’s try to understand this problem with an example. Consider the input number of rows…

https://thecodingbot.com/printing-complete-star-triangle-in-c/
Two ways to reverse a number in C++

Problem Statement Given an integer, the task is to find the reverse of it. It is sure that number as well as it’s reverse fits in the range of an integer. Example: Input: 3421 Output: 1243 Approach 1 – Constructing the reverse using the original number Step 1: Check if the number is negative or not.…

https://thecodingbot.com/two-ways-to-reverse-a-number-in-c/
Python’s list reverse() function with examples

Overview In this tutorial, we will discuss Python list’s built-in method –reverse(). Talking about the built-in methods, they are the utility methods provided by the Python interpreter for our use; and they come along when you install Python in your environment. They provide us the implementation of many common operations like conversion of an integer…

https://thecodingbot.com/pythons-list-reverse-function-with-examples/
Print inverted half star triangle pattern in C++

Problem Statement Given the number of rows, form an inverted half triangle pattern made up of stars(asterisks) â€ś*”. For Example Input: 5 Output: Inverted half star triangle pattern in C++ Solution This is an easy problem which can be solved simply using nested loops. Let’s try to understand this problem with an example. Consider the input number…

https://thecodingbot.com/print-inverted-half-star-triangle-pattern-in-c/
Python program to split a given list into Even and Odd list based on the parity of the numbers

Problem Statement Given a python list consisting of integers, based on their parity, separate them into even and odd list. For example: Input: list = [1,4,6,87] Output: even_list = [4,6] , odd_list = [1,87] The problem statement is pretty clear – we have a list of integers and we need to separate them into two…

https://thecodingbot.com/python-program-to-split-a-given-list-into-even-and-odd-list-based-on-the-parity-of-the-numbers/
Time and Space complexity analysis of Python’s list.reverse method

Overview In this article, we will explicitly focus on the Time and Space Complexity of Python List’s reverse() method. If you wish to read a complete detailed tutorial on the method then you can find it here. Before moving forward, let’s quickly recall what does the reverse() function do when applied to a list. list.reverse list.reverse() is…

https://thecodingbot.com/time-and-space-complexity-analysis-of-pythons-list-reverse-method/
Channel name was changed to «Computer programming»
Leetcode – 771. Jewels and Stones

Problem Statement You’re given strings J representing the types of stones that are jewels, and S representing the stones you have.  Each character in S is a type of stone you have.  You want to know how many of the stones you have are also jewels. The letters in J are guaranteed distinct, and all…

https://thecodingbot.com/leetcode-771-jewels-and-stones/
How to print a statement in C/C++ without a semicolon(;) – Different methods

Problem Statement The task is to print a statement, say “Hello World“, without using a semicolon in C/C++. Solution To be honest, this isn’t a serious programming question, but, it is possible that you might face this question in an interview someday. It is a kind of puzzle problem. There are many different ways to…

https://thecodingbot.com/how-to-print-a-statement-in-c-c-without-a-semicolon-different-methods/
Insert a Node at the beginning of a Linked List

Problem Statement Given a linked list(can be an empty list), add a node at the beginning of it. For example: Linked list before insertion = 4->3->5->NULL Input Integer = 51 Linked list after insertion = 51->4->3->5->NULL Linked list before insertion = 40->13->95->NULL Input Integer = 141 Linked list after insertion = 141->40->13->95->NULL Solution This is…

https://thecodingbot.com/insert-a-node-at-the-beginning-of-a-linked-list/