
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 10476 Articles for Python

4K+ Views
Suppose we want to design a HashSet data structure without using any built-in hash table libraries. There will be different functions like −add(x) − Inserts a value x into the HashSet.contains(x) − Checks whether the value x is present in the HashSet or not.remove(x) − Removes x from the HashSet. In case the value does not exist in the HashSet, do nothing.So, to test it Initialize the hash set, then call add(1), add(3), contains(1), contains(2), add(2), contains(2), remove(2), contains(2)., then the output will be true (1 is present), false (2 is not present), true (2 is present), false (2 is ... Read More

574 Views
Suppose we want to design a class to find the kth largest element in a stream. It is the kth largest element in the sorted order, not the kth distinct element.The KthLargest class will have a constructor which accepts an integer k and an array nums, that will contain initial elements from the stream. For each call to the method KthLargest.add, will return the element representing the kth largest element in the stream.So, if the input is like k = 3, initial elements = [4, 5, 8, 2], then call add(3), add(5), add(10), add(9), add(4). , then the output will ... Read More

264 Views
Suppose we have a data structure of employee information, there are employee's unique id, his importance value and his direct subordinates' id. As an example, employee 1 is the leader of employee 2, and employee 2 is the leader of employee 3. And suppose their importance values are 15, 10 and 5, respectively. Then employee 1 has a data structure like [1, 15, [2]], and employee 2 has [2, 10, [3]], and employee 3 has [3, 5, []].So, if we have the employee information of a company, and an employee id, we have to find the total importance value of ... Read More

2K+ Views
Suppose we have a baseball game point recorder. We have a list of strings; each string can be one of the 4 following types −Integer (one round's score) − Indicates the number of points we get in this round."+" (one round's score) − Indicates the points we get in this round are the sum of the last two valid round's points."D" (one round's score ) − Indicates the points we get in this round are the doubled data of the last valid round's points."C" (an operation, which isn't a round's score) − Indicates the last valid round's points we get ... Read More

867 Views
Suppose we have a binary tree we have to make a string consists of parenthesis and integers from a binary tree with the preorder traversing way. A null node will be represented by empty parenthesis pair "()". And we need to omit all the empty parenthesis pairs that don't affect the one-to-one mapping relationship between the string and the original binary tree.So, if the input is likethen the output will be 5(6()(8))(7)To solve this, we will follow these steps −ans := blank stringDefine a function pot(). This will take node, sif is null, thenreturn blank stringif if left or right ... Read More

302 Views
Suppose we have to design a standard heater with a fixed warm radius to warm all the houses. Now, we have given positions of houses and heaters on a horizontal line, we have to find the minimum radius of heaters so that all houses could be covered by those heaters. So, we will provide houses and heaters separately, and our expected output will be the minimum radius standard of heaters.So, if the input is like [1, 2, 3, 4], [1, 4], then the output will be 1 as the two heaters was placed in position 1 and 4. We have ... Read More

355 Views
Suppose we have n points in the plane that are all pairwise distinct. Now a "boomerang" is a tuple of points like (i, j, k) such that the distance between i and j is the same as the distance between i and k. We have to find the number of boomerangs.So, if the input is like [[0, 0], [1, 0], [2, 0]], then the output will be 2, as two boomerangs are [[1, 0], [0, 0], [2, 0]] and [[1, 0], [2, 0], [0, 0]].To solve this, we will follow these steps −counter_of_boomerangs := 0for each point_1 in points array, ... Read More

212 Views
Suppose we have an array num and another value val, we have to remove all instances of that value in-place and find the new length.So, if the input is like [0, 1, 5, 5, 3, 0, 4, 5] 5, then the output will be 5.To solve this, we will follow these steps −count := 0for each index i of numsif nums[i] is not equal to val, then −nums[count] := nums[i]count := count + 1return countExampleLet us see the following implementation to get a better understanding − Live Democlass Solution: def removeElement(self, nums, val): count = 0 ... Read More

7K+ Views
IPv4 and IPv6 are internet protocol versions, with IPv6 being an upgraded version of IPv4. There are several differences between the IPv4 and IPv6 protocols, including their functionality, but the most important difference is the quantity of addresses (Address space) that they create.Read through this article to find out more about IPv4 and IPv6 and how they are different from each other.What is Internet Protocol (IP)?The Internet Protocol is a set of rules that allows our computers to communicate via the Internet. IP addresses are basically in charge of directing the data packets to their correct destinations. IP controls all ... Read More

2K+ Views
Suppose we have a number. The number can be anything in between 0 to 231 – 1. We have to convert the number into words. So if the number is like 512, then the result will be Five hundred twelve.To solve this, we will follow these steps −Define some lists like less_than_20, this will hold all words from one to nineteenAnother array like tens to hold tens, twenty, thirty and so on up to ninetyAnother array for thousands, to hold thousand, million and billionDefine one function called helper(), this will take nif n is 0, then return blank stringotherwise when ... Read More