Found 34472 Articles for Programming

Golang program to find the union of two arrays

Aman Sharma
Updated on 10-Jul-2023 17:24:56

430 Views

In Golang, like other programming languages, we can find the union of two arrays. The union of two arrays is a list that consists of elements that lie in array A and the elements that lie in array B and common elements that lie in both arrays. For example, we have two arrays listed below A = {2, 9, 5, 7, 3} B = {5, 8, 7 2, 1} The union of the above arrays will be Union = {1, 2, 3, 5, 7, 8, 9} Method 1 In this method, we are going to find the union of two ... Read More

Golang Program to Find Max No. of 1 in a Sorted Row of the Matrix

Aman Sharma
Updated on 10-Jul-2023 17:23:48

66 Views

In programming languages, we can create 2−Dimensional Matrices and store elements in them. The 2−Dimensional metric is a data structure that has rows and columns. In this article, we are going to see the two different logic to find the maximum no. of ones in a sorted row of the matrix. For example, we have below the matrix {0, 1, 1, 1}, no. of 1s = 3 {0, 0, 1, 1}, no. of 1s = 2 {1, 1, 1, 1}, no. of 1s = 4 {0, 0, 0, 0}, no. of 1s = 0 In the ... Read More

Golang program to find duplicates in N+1 array

Aman Sharma
Updated on 10-Jul-2023 17:22:26

738 Views

In programming, there is a problem statement asked in interviews to find the duplicate number in an array of size N + 1. Also, there will be only one duplicate element in the array. The elements will be between 1 to N. For example, Array = {1, 3, 2, 1, 4} 1 is the duplicate element in the above array. Algorithm Step 1: Import the required packages at the top using the import keyword. Step 2: Then the main function will get run first. First, we are declaring and initialize the array. Now, we are calling the function to ... Read More

Golang Program Right View of Binary Tree

Aman Sharma
Updated on 10-Jul-2023 15:12:35

86 Views

In programming, there is a coding problem of binary tree that gets asked very frequently in interviews and the problem statement is to find the right view of a binary tree. If we try to understand the problem statement more than what exactly the right view is then we can explain it in a way that all the nodes are visible when you see them by standing on the right side of the tree. Illustration Let us understand more with the help of an example. Suppose we have a below tree and if we stand on the right side ... Read More

Golang Program Level Order Traversal of Binary Tree

Aman Sharma
Updated on 10-Jul-2023 17:20:06

258 Views

In programming, there are different data structures to store data. There are two different types of data structures linear and non −linear. Array, stack, queue, and linked list are linear data structures. Binary trees, trie, etc are non − linear data structures. In this article, we are going to explore level order traversal on one of the non − linear data structures i.e. binary tree. Level Order Traversal In level order traversal, of a binary tree we start from the root node and then traverse the children nodes and move to the children of children nodes. In this way, ... Read More

Golang Program Left View of Binary Tree

Aman Sharma
Updated on 10-Jul-2023 17:17:31

113 Views

In programming, there is a coding problem of binary tree that gets asked very frequently in interviews and the problem statement is to find the left view of a binary tree. If we try to understand the problem statement more than what exactly the left view is then we can explain it in a way that all the nodes are visible when you see them by standing on the left side of the tree. Illustration Let us understand more with the help of an example. Suppose we have a below tree and if we stand on the left side ... Read More

Golang program Breadth-First Search graph

Aman Sharma
Updated on 10-Jul-2023 17:15:46

929 Views

Graph is a data structure that consists of edges or we can say nodes and vertices. Vertices are the lines between the nodes. To traverse all these nodes we have different traversal algorithms. In this article, we will discuss, Breadth − first search or we can say BFS. In Breadth − first search, we first start from one node and move to another till the dead end comes. Example If we start from node 1 then it will first visit node 2 and node 4 first. Then from node 2, we will visit node 3. In this way, the ... Read More

How to Replace Values in Columns Based on Condition in Pandas

Rohan Singh
Updated on 10-Jul-2023 14:21:50

7K+ Views

In Python, we can replace values in Column based on conditions in Pandas with the help of various inbuilt functions like loc, where and mask, apply and lambda, etc. Pandas is a Python library that is used for data manipulation and work with structured data. In this article, we will replace values in columns based on conditions in Pandas. Method 1: Using loc The loc function is used to access a group of rows and columns in a DataFrame. We can use this function to replace values in a column based on some condition. Syntax df.loc[row_labels, column_labels] The loc ... Read More

Faulty calculator using Python

Rohan Singh
Updated on 10-Jul-2023 14:13:42

146 Views

A faulty calculator in Python is a calculator that gives incorrect results for certain calculations. In Python, we can create our own calculator and use it for doing mathematical calculations. If we want to create a faulty calculator we need to create or introduce errors in the functions that perform the calculations. In this article, we will create a faulty calculator using Python. Creating a faulty Calculator Creating a faulty calculator is easy as we need to just introduce some incorrect calculations in the normal calculator in the code to give an incorrect result which converts it into a ... Read More

How to replace a word in Excel using Python?

Rohan Singh
Updated on 10-Jul-2023 14:17:35

1K+ Views

In Python, we can replace a word in Excel with another word using a third-party Python library called openpyxl. Microsoft Excel is a useful tool that is used for managing and analyzing data. Using Python we can automate some of the Excel data management tasks. In this article, we will understand how we can replace a word in Excel using Python. Installing openpyxl Before implementing the program to replace Word in Excel we need to install the openpyxl library in our system using the Python package manager. To install openpyxl type the following command on your terminal or command ... Read More

Advertisements