
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 33676 Articles for Programming

1K+ Views
Suppose we have a string s that is representing a phrase, we have to find its acronym. The acronyms should be capitalized and should not include the word "and".So, if the input is like "Indian Space Research Organisation", then the output will be ISROTo solve this, we will follow these steps −tokens:= each word of s as an arraystring:= blank stringfor each word in tokens, doif word is not "and", thenstring := string concatenate first letter of wordreturn convert string into uppercase stringLet us see the following implementation to get better understanding −Example Live Democlass Solution: def solve(self, s): ... Read More

318 Views
Problem Statement Consider a mobile phone, which is in "eco mode". This mode activates once your battery level reaches 20 percent. In this eco mode, the battery drains two times slower than in normal mode. This means that, in normal mode, if the time consumed by the battery is 1% per minute, then the time taken in eco mode is 1% per 30 seconds (1/2 minute). Scenario Now, when we leave our home, we have 100% of the battery. Then t minutes later we have p percent of battery left. We have to find how many minutes we have until ... Read More

348 Views
Suppose we have a positive number n, we have to find that we can make n by summing up some non-negative multiple of 3 and some non-negative multiple of 7 or not.So, if the input is like 13, then the output will be True, as 13 can be written as 1*7+2*3 = 13To solve this, we will follow these steps −for i in range 0 to n+1, increase by 7, doif n-i is divisible by 3, thenreturn Truereturn FalseLet us see the following implementation to get better understanding −Example Live Democlass Solution: def solve(self, n): for i ... Read More

889 Views
Suppose we have a number n, we have to construct a list with each number from 1 to n, except when it is multiple of 3 or has a 3, 6, or 9 in the number, it should be the string "no-fill".So, if the input is like 20, then the output will be ['1', '2', 'clap', '4', '5', 'clap', '7', '8', 'clap', '10', '11', 'clap', 'clap', '14', 'clap', 'clap', '17', 'clap', 'clap', '20']To solve this, we will follow these steps −string := "no-fill"ls:= make a list of numbers as string from 1 to nfor i in range 0 to size ... Read More

4K+ Views
Suppose we have a string s. Here s is representing a 12-hour clock time with suffixes am or pm, we have to find its 24-hour equivalent.So, if the input is like "08:40pm", then the output will be "20:40"To solve this, we will follow these steps −hour := (convert the substring of s [from index 0 to 2] as integer) mod 12minutes := convert the substring of s [from index 3 to 5] as integerif s[5] is same as 'p', thenhour := hour + 12return the result as hour:minutesLet us see the following implementation to get better understanding −Example Live Democlass Solution: ... Read More

380 Views
Suppose we have an integer n, where only 1, 2, and 3 these digits are present. We can flip one digit to a 3. Then find the maximum number we can make.So, if the input is like 11332, then the output will be 31332To solve this, we will follow these steps −li := a list by digits of nfor x in range 0 to size of li - 1, doif li[x] is not '3', thenli[x] := '3'return the number by merging digits from lireturn nLet us see the following implementation to get better understanding −Example Live Democlass Solution: def solve(self, ... Read More

353 Views
Suppose we have a lowercase alphabet string s, we have to find the length of the shortest substring (minimum length is 2) such that some letter appears more than the other letters combined. If we cannot find any solution, then return -1.So, if the input is like "abbbcde", then the output will be 2, the substring "bb" has minimum length and this appears more than other letters.To solve this, we will follow these steps −Define a function ok(), this will take an array cnt, total := 0, maxVal := 0for each element it in cnt, dototal := total + itmaxVal ... Read More

339 Views
Suppose we have a list of numbers. We have to define a method that can rotate a list of numbers to the left by k elements.So, if the input is like [5, 4, 7, 8, 5, 6, 8, 7, 9, 2], k = 2, then the output will be [8, 5, 6, 8, 7, 9, 2, 5, 4, 7]To solve this, we will follow these steps −Define an array retn := size of numsk := k mod nfor initialize i := k, when i < n, update (increase i by 1), do −insert nums[i] at the end of retfor initialize ... Read More

310 Views
Suppose we have a list of intervals where each interval contains the [start, end] times. We have to find the minimum total size of any two non-overlapping intervals, where the size of an interval is (end - start + 1). If we cannot find such two intervals, return 0.So, if the input is like [[2, 5], [9, 10], [4, 6]], then the output will be 5 as we can pick interval [4, 6] of size 3 and [9, 10] of size 2.To solve this, we will follow these steps −ret := infn := size of vsort the array v based ... Read More

306 Views
Suppose we have a string s containing only '(' and ')', we have to find the minimum number of brackets that can be inserted to make the string balanced.So, if the input is like "(()))(", then the output will be 2 as "(()))(", this can be made balanced like "((()))()".To solve this, we will follow these steps −:= 0, cnt := 0for initialize i := 0, when i < size of s, update (increase i by 1), do −if s[i] is same as '(', then −(increase o by 1)Otherwiseif o is non-zero, then −(decrease o by 1)Otherwise(increase cnt by 1)return ... Read More