
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

571 Views
Suppose we have a string s and and a value k. The value of k is factor of the length of s, say the length is n. We can split s into n/k different substrings called t_i of size k. Then use these t_i to make u_i such thatThe characters present in u_i are subsequence of characters in t_iAny repeat characters will be removed from these string such that frequency of each character in u_i is 1We have to find these u_i stringsSo, if the input is like s = "MMPQMMMRM" k = 3, then the output will be ["MP", ... Read More

463 Views
Suppose there are two players Amal and Bimal. They are playing a game. The game rules are as follows −Both players have a same string s.Both of them have to make substrings using the letters of s.Bimal has to make words starting with consonants.Amal has to make words starting with vowels.The game will end when both players have made all possible substrings.Now the scoring criteria is like: a player gains 1 point for each occurrence of the substring in the string s. We have to find winner of this game and his score.So, if the input is like s = ... Read More

245 Views
Suppose we have a list of numbers called nums with positive and negative numbers. We have to update this list so that the final list will only hold the absolute value of each element.So, if the input is like nums = [5, -7, -6, 4, 6, -9, 3, -6, -2], then the output will be [5, 7, 6, 4, 6, 9, 3, 6, 2]To solve this, we will follow these steps −Solve this by map and list operationsdefine one anonymous function say l, that takes x as argument and returns abs(x)using map() method convert each element e from nums to ... Read More

762 Views
Suppose we have a list nums. We have to find the length of this list but without using any length(), size() or len() type of functions.So, if the input is like nums = [5, 7, 6, 4, 6, 9, 3, 6, 2], then the output will be 9.To solve this, we will follow these steps −Solve this by map and list operationsx := a list which contains all elements in numsconvert all elements in x to 1find sum of x by using sum() methodIn this example we have used the map() method to convert all into 1 by defining an ... Read More

7K+ Views
In Python you can find the sum of all odd elements in an existing List one of the following ways - Using List Comprehension Using a Loop Using filter() Function Using List Comprehension The List Comprehension method allows us to create a new list ... Read More

255 Views
Suppose we have a list of n elements called nums. We have to reverse this list by list slicing operations.So, if the input is like nums = [5, 7, 6, 4, 6, 9, 3, 6, 2], then the output will be [2, 6, 3, 9, 6, 4, 6, 7, 5]To solve this, we will follow these steps −list slicing takes at most three parameters separated by colon. First one is start, second one is end and third one is stephere as we start from 0 we do not pass first parameter, as we end at n, we also not providing ... Read More

3K+ Views
Suppose we have a number n. We have to create a list of elements of size n, the elements are from 1 to n.So, if the input is like n = 5, then the output will be [1, 2, 3, 4, 5]To solve this, we will follow these steps −use python list comprehension strategy to solve this problemcreate a list with i for each i from 1 to n, for this we use range() function. This will take lower bound which is n here, and upper bound n+1 because we want to generate up to n.ExampleLet us see the following ... Read More

450 Views
Suppose we have a number n. We have to find divisor of n which one is better based on these conditions: We have two numbers p and q, the one whose digits sum to a larger number is called better than the other one. When the sum of digits is same, then the smaller number is the better one.So, if the input is like n = 180, then the output will be 9 because the divisors are [1, 2, 3, 4, 5, 6, 9, 10, 12, 15, 18, 20, 30, 36, 45, 60, 90, 180]. So the number whose digit ... Read More

682 Views
Suppose we have a set of heights there may be some duplicate entries as well. We have to find the average of distinct entries of these heights.So, if the input is like heights = [96, 25, 83, 96, 33, 83, 24, 25], then the output will be 52.2 because the unique elements are [96, 25, 83, 33, 24], so sum is 96 + 25 + 83 + 33 + 24 = 261, average is 261/5 = 52.2.To solve this, we will follow these steps −h_set := a set from heights to remove duplicatesreturn sum of h_set items / size of ... Read More

2K+ Views
Suppose we have a list of elements called nums. We have to filter out all odd indexed elements, so only return even indexed elements from that list.So, if the input is like nums = [5,7,6,4,6,9,3,6,2], then the output will be [7, 4, 9, 6]To solve this, we will follow these steps −use python list slicing strategy to solve this problemstart from index 1, end at the end of list and increase each step by 2, so the slicingsyntax is [1::2]ExampleLet us see the following implementation to get better understanding −def solve(nums): return nums[1::2] nums = [5,7,6,4,6,9,3,6,2] print(solve(nums))Input[5,7,6,4,6,9,3,6,2]Output[7, 4, 9, 6]