Articles on Trending Technologies

Technical articles with clear explanations and examples

Append multiple lists at once in Python

Pradeep Elance
Pradeep Elance
Updated on 11-Mar-2026 8K+ Views

For various data analysis work in python we may be needed to combine many python lists into one list. This will help processing it as a single input list for the other parts of the program that need it. It provides performance gains by reducing number of loops required for processing the data further.Using + operatorThe + operator does a straight forward job of joining the lists together. We just apply the operator between the name of the lists and the final result is stored in the bigger list. The sequence of the elements in the lists are preserved.ExamplelistA = ...

Read More

Binary Tree Maximum Path Sum in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 984 Views

Suppose we have one non-empty binary tree. We have to find the path sum. So here, a path is any sequence of nodes from some starting node to any node in the where the parent-child connections are present. The path must contain at least one node and does not need to go through the root node. So if the input tree is −Here the output will be 32.To solve this, we will follow these steps −Define one method called solve(), this will take nodeif node is null or the value of node is 0, then return 0left := max of ...

Read More

Count All Valid Pickup and Delivery Options in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 250 Views

Suppose we have a list of n orders, in each order there are pickup and delivery services. We have to count all valid pickup/delivery possible sequences such that delivery[i] is always after the pickup[i]. As the answer may very large, we will return it modulo 10^9 + 7.So, if the input is like 2, then the output will be 6, as All possible orders are (P1, P2, D1, D2), (P1, P2, D2, D1), (P1, D1, P2, D2), (P2, P1, D1, D2), (P2, P1, D2, D1) and (P2, D2, P1, D1). And the order (P1, D2, P2, D1) is not valid ...

Read More

Find sum of frequency of given elements in the list in Python

Pradeep Elance
Pradeep Elance
Updated on 11-Mar-2026 552 Views

A given list has many repeated items. We are interested in finding out the sum of the frequency of some such items which are repeated in the list. Below are the approaches how we can achieve this.With sumWe have two lists. One has the list of values and other has the values whose frequency needs to be checked from the first list. So we create a for loop to count the number of occurrences of the elements from the second list in the first list and then apply the sum function to get the final sum of frequency.Examplechk_list= ['Mon', 'Tue'] ...

Read More

Assign multiple variables with a Python list values

Pradeep Elance
Pradeep Elance
Updated on 11-Mar-2026 2K+ Views

Depending on the need of the program we may an requirement of assigning the values in a list to many variables at once. So that they can be further used for calculations in the rest of the part of the program. In this article we will explore various approaches to achieve this.Using for inThe for loop can help us iterate through the elements of the given list while assigning them to the variables declared in a given sequence.We have to mention the index position of values which will get assigned to the variables.ExamplelistA = ['Mon', ' 2pm', 1.5, '11 miles'] ...

Read More

Longest Consecutive Sequence in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 5K+ Views

Suppose we have an array of integers. We have to find the length of the longest consecutive elements sequence. So if the input is like [100, 4, 250, 1, 3, 2], answer will be 4, as the longest consecutive sequence is [1, 2, 3, 4].To solve this, we will follow these steps −make the array set, longest := 0for i in range array −if i – 1 is not in a −current := i, streak := 0while i in a −increase i by 1, increase streak by 1longest := max of longest and streakreturn longestExampleLet us see the following implementation ...

Read More

Largest Multiple of Three in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 202 Views

Suppose we have one array of digits, we have to find the largest multiple of three that can be formed by concatenating some of the given digits in any order as we want. The answer may be very large so make it as string. If there is no answer return an empty string.So, if the input is like [7, 2, 8], then the output will be 87To solve this, we will follow these steps −Define one 2D array d, there will be three rowssort the array digitssum := 0for initialize i := 0, when i < size of digits, update ...

Read More

Finding frequency in list of tuples in Python

Pradeep Elance
Pradeep Elance
Updated on 11-Mar-2026 579 Views

Many different types of data container can get mixed up in python. A list can have elements each of which is a tuple. In this article we will take such a list and find the frequency of element in the tuples which are themselves elements of a list.Using count and mapWe apply a lambda function to count through each of the first element in the tuples present in the list. Then apply a map function to arrive at the total count of the element we are searching for.Example# initializing list of tuples listA = [('Apple', 'Mon'), ('Banana', 'Tue'), ('Apple', 'Wed')] ...

Read More

Assign range of elements to List in Python

Pradeep Elance
Pradeep Elance
Updated on 11-Mar-2026 652 Views

Lists are very frequently used data container in Python. While using lists we may come across a situation where the elements of the list maybe a sequence of numbers. We can add this sequence of numbers to a list using many Python functions. In this article we will explore different ways of doing that.With range and extendThe extent function allows us to increase the number of elements in a list. Will use the range function and apply extend to the list so that all the required sequence of numbers are added at the end of the list.ExamplelistA = [55, 91, ...

Read More

Palindrome Partitioning II in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 217 Views

Suppose we have a string s, we have to find the number of cuts needed to divide this string into different substring and each part is a palindrome. So if the string is like “ababba”, then this will take 2 cuts. [aba|bb|a]To solve this, we will follow these steps −n := number of characters in the string screate one array called res of size n + 1res[n] := -1for i in range n – 1 down to 0res[i] := n – i – 1for j in range i to nif substring of a, from index i, to j – i ...

Read More
Showing 5211–5220 of 61,248 articles
« Prev 1 520 521 522 523 524 6125 Next »
Advertisements