Category: python
A stack is a first-in-last-out (FILO) data structure. We all know that the list/array in Python is very powerful, that it can be used as a stack itself. For …
Given two integers L and R, find the count of numbers in the range (inclusive) having a prime number of set bits in their binary representation. (Recall that the …
In Python, we can check if an array or list contains duplicate items using the following one-liner function. def contain_duplicates(list): return len(set(list)) != len(list) The idea is to convert …
Given three integer arrays arr1, arr2 and arr3 sorted in strictly increasing order, return a sorted array of only the integers that appeared in all three arrays. Example 1: …
You may see Python code like this: for i,v in enumerate(data): pass So, what does the enumerate() function do? The enumerate() in python takes a list as its first …