
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

485 Views
Suppose we have a string S and we have to write the letters of that given string, from left to right into lines. Here each line has maximum width 100 units, and if writing a letter would cause the width of the line to exceed 100 units, that will be written on the next line. We also have an array widths, here widths[0] is the width of 'a', widths[1] is the width of 'b'and so on.We have to find the answers of two questions −How many lines have at least one character from SWhat is the width used by the ... Read More

576 Views
Suppose we have a list of words, here each word can be written as a concatenation of the Morse code of each letter. For example, the word "cba" can be written as "-.-..--...", this is the concatenation "-.-." | "-..." | ".-"). This kind of concatenation is called the transformation of a word.We know that International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: "a" maps to ".-", "b" maps to "-...", "c" maps to "-.-.", and so on.Here is the list of all 26 letters of the ... Read More

287 Views
Suppose we have two integers L and R, we have to find the count of numbers in the range [L, R] (inclusive) having a prime number of set bits in their binary form.So, if the input is like L = 6 and R = 10, then the output will be 4, as there are 4 numbers 6(110), 7(111), 9(1001), 10(1010), all have prime number of set bits.To solve this, we will follow these steps −count := 0for j in range L to R, doif set bit count of j is in [2, 3, 5, 7, 11, 13, 17, 19], thencount ... Read More

383 Views
Suppose we have a dictionary words, and we have to find the minimum length word from a given dictionary words, it has all the letters from the string licensePlate. Now such a word is said to complete the given string licensePlate. Here, we will ignore case for letters. And it is guaranteed an answer exists. If there are more than one answers, then return answer that occurs first in the array.The license plate there may be same letter occurring multiple times. So when a licensePlate of "PP", the word "pile" does not complete the licensePlate, but the word "topper" does.So, ... Read More

429 Views
Suppose we have an integer array called nums, now there is always exactly one largest element. We have to check whether the largest element in the array is at least twice as much as every other number in the array. If it is so, then we have to find the index of the largest element, otherwise return -1.So, if the input is like [3, 6, 1, 0], then the output will be 1, as 6 is the largest number, and for every other number in the array x, 6 is more than twice as big as x. As the index ... Read More

872 Views
Suppose there is a staircase, here the i-th step will be some non-negative cost value cost[i] assigned. When we pay the cost, we can either climb one or two steps. We have to find minimum cost to reach the top of the floor, and we also can either start from the step with index 0, or the step with index 1.So, if the input is like cost = [12, 17, 20], then the output will be 17, The cheapest position to start from step 1 as we have to pay that cost and go to the top.To solve this, we ... Read More

1K+ Views
Suppose we have a list of sorted characters’ letters. This is containing only lowercase letters, now we have a target letter t, we have to find the smallest element in the list that is larger than the given target.And letters also wrap around. So, if the target is t = 'z' and letters = ['a', 'b'], the answer is 'a'.So, if the input is like ["c", "f", "j"], t = 'a', then the output will be 'c'.To solve this, we will follow these steps −l := 0r := size of letters - 1while l target, thenr := mid -1otherwise, ... Read More

535 Views
Suppose we have a list of words representing an English Dictionary, we have to find the longest word in the given word list that can be built one character at a time by other words in words. If there is more than one possible answer, then return the longest word with the smallest lexicographical order. If there is no answer, then return the empty string.So, if the input is like ["h", "he", "hel", "hell", "hello"], then the output will be "hello"To solve this, we will follow these steps −trie := a new mapDefine a function insert(). This will take wordnow ... Read More

622 Views
What Are 1-bit and 2-bit Characters? In computers, everything is stored in the form of bits, i.e., the smallest pieces of data that can be either 0 or 1. Now, when we talk about 1-bit or 2-bit characters, we mean how many of these bits are used to make a single character (like a letter or symbol). A 1-bit character is just a single 0. It counts as one character by itself. A 2-bit character is made of two bits and can be either 10 or 11. If we are given a list of bits (containing only 0s ... Read More

2K+ Views
Suppose we want to design a HashMap without using any built-in hash table libraries. There will be different functions as follows −put(key, value) − This will insert a value associated with key into the HashMap. If the value already exists in the HashMap, update the value.get(key) − This will return the value to which the specified key is mapped, otherwise -1 when this map contains no mapping for the key.remove(key) − This will Remove the mapping for the value key if this map contains the mapping for the key.So, if the input is like After initialization, call the put and ... Read More