
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 26504 Articles for Server Side Programming

2K+ Views
Suppose we have an array called nums of positive integers. We have to select some subset of nums, then multiply each element by an integer and add all these numbers. The array will be a good array if we can get a sum of 1 from the array by any possible subset and multiplicand.We have to check whether the array is good or not.So, if the input is like [12, 23, 7, 5], then the output will be True, this is because If we take numbers 5, 7, then 5*3 + 7*(-2) = 1To solve this, we will follow these ... Read More

3K+ Views
In this article we will find all those elements from a list which start with specific letter.With index and lowerWe use the lower function so that the test later can match with the first letter of the the elements in the list irrespective of the case. Then we use the index at 0 so that the first letter of the elements in a list are compared with the test letter.Example Live DemolistA = ['Mon', 'Tue', 'Wed', 'Thu'] # Test with letter test = 'T' # printing original list print("Given list " ,listA) # using lower and idx res = [idx for ... Read More

8K+ Views
In this article we will see how to find the element which is most common in a given list. In other words, the element with highest frequency.With max and countWe apply why the set function to get the unique elements of the list and then keep account of each of those elements in the list. Finally apply a max function to get the element with highest frequency.Example Live Demo# Given list listA = [45, 20, 11, 50, 17, 45, 50, 13, 45] print("Given List:", listA) res = max(set(listA), key = listA.count) print("Element with highest frequency:", res)OutputRunning the above code gives us ... Read More

675 Views
A 2D list has list as its element. In other words it is a list of lists. In this article we are required to find the element which is most common among all the lists inside a list.With max and countWe design a follow with a in condition to check for the presence of an element in a given sublist. Then we apply the max function along with the count function to get the the element with maximum frequency.Example Live Demodef highest_freq(lst): SimpleList = [el for sublist in lst for el in sublist] return max( SimpleList, key= SimpleList.count) # ... Read More

312 Views
Suppose we have a rectangle of size n x m. We have to find the minimum number of integers sided square objects that can tile the rectangles.So, if the input is like n = 2 and m = 3,then the output will be 3, as we need three blocks.To solve this, we will follow these steps −Define one map mres := infDefine a function dfs(), this will take n, m, an array h, cnt,if cnt >= res, then −returnisFull := truepos := -1, minH := inffor initialize i := 1, when i

387 Views
We are given a list of lists. In the inner lists or sublists we are required to find the maximum value in each.With max and inWe design a for loop with in condition and apply the max function to get the maximum value in each of the sublist.Example Live DemoAlist = [[10, 13, 454, 66, 44], [10, 8, 7, 23]] # Given list print("The given list: ", Alist) # Use Max res = [max(elem) for elem in Alist] # Printing max print("Maximum values from each element in the list: ", res)OutputRunning the above code gives us the following result −The given ... Read More

1K+ Views
Suppose we have n different tasks, where every task is scheduled to be done from startTime[i] to endTime[i], for that task we algo get profit of profit[i]. We know the startTime , endTime and profit lists, we have to find the maximum profit we can take such that there are no 2 tasks in the subset with overlapping time range. If we choose a task that ends at time X we will be able to start another task that starts at time X.So, if the input is like startTime = [1, 2, 3, 3], endTime = [3, 4, 5, 6] ... Read More

572 Views
A list is made up of tuples as its element. In this article we will count the number of unique tuples present in the list.With defaultdictWe treat the given list as a defaultdict data container and count the elements in it using the in condition.Example Live Demoimport collections Alist = [[('Mon', 'Wed')], [('Mon')], [('Tue')], [('Mon', 'Wed')] ] # Given list print("Given list:", Alist) res = collections.defaultdict(int) for elem in Alist: res[elem[0]] += 1 print("Count of tuples present in the list:", res)OutputRunning the above code gives us the following result −Given list: [[('Mon', 'Wed')], ['Mon'], ['Tue'], [('Mon', 'Wed')]] Count of tuples ... Read More

406 Views
The elements in a given list can also be present as another string in another variable. In this article we'll see how many times a given stream is present in a given list.With range and lenWe use the range and len function to keep track of the length of the list. Then use the in condition to find the number of times the string is present as an element in a list. A count variable initialized to zero keeps incrementing whenever the condition is met.Example Live DemoAlist = ['Mon', 'Wed', 'Mon', 'Tue', 'Thu'] Bstring = 'Mon' # Given list print("Given ... Read More

272 Views
Suppose we have an array nums of positive integers, we have to return the longest possible length of an array prefix of given array nums, such that it is possible to delete exactly one element from this prefix so that every number that has appeared in it will have the same frequency. After removing one element if there are no remaining elements, it's still considered that every appeared number has the same frequency (0).So, if the input is like [3, 3, 2, 2, 6, 4, 4, 6], then the output will be 7, So if we remove element 6 from ... Read More