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
Server Side Programming Articles - Page 1381 of 2650
355 Views
Suppose we have a string s and another character c, we have to check whether all occurrences of c appear together in s or not. If the character c is not present in s then also return true.So, if the input is like s = "bbbbaaaaaaaccddd", c = 'a', then the output will be True.To solve this, we will follow these steps −flag := Falseindex := 0n := size of stringwhile index < n, doif string[index] is same as c, thenif flag is True, thenreturn Falsewhile index < n and string[index] is same as c, doindex := index + 1flag ... Read More
183 Views
Suppose we have a matrix mat. There are few different values as follows The cells of matrix can hold any of these 3 characters0 for empty area.1 for bomb.2 for Enemies.Now bomb can blast in only horizontal and vertical directions from one end to another. We have to check whether all enemies will die when bomb explodes or not.So, if the input is like0020010002000010then the output will be True, because bomb at place [1, 1] can fill enemy at place [2, 1] and enemy at [0, 2] will be killed by bomb placed at [3, 2].To solve this, we will ... Read More
2K+ Views
Suppose we have a list of numbers nums. We have to check whether the list is palindrome or not.So, if the input is like nums = [10, 12, 15, 12, 10], then the output will be True.To solve this, we will follow these steps −n := size of numsreset is_palindromei := 0while i
694 Views
Suppose we have a number n. We have to check whether all digits of it can divide n or not.So, if the input is like n = 135, then the output will be True, because (135 / 1 = 135), (135 / 3 = 45) and (135 / 5 = 27).To solve this, we will follow these steps −val := nwhile val > 0, dod := val mod 10if n is not divisible by d, thenreturn Falseval := quotient of (val / 10)return TrueLet us see the following implementation to get better understanding −Example Live Demodef is_divisible(n, d) : return ... Read More
454 Views
In computers, data is stored in the binary form, which uses the two digits 0 and 1. Each digit in this format is known as a bit. In this article, we are going to check if all bits of a number are set in Python. A bit is said to be set if the binary representation of every bit is 1. Let's look at some scenarios to understand this better: Scenario 1 Input: 3 Binary: 111 Output: True Explanation: All bits are 1. Scenario 2 Input: 6 Binary: 110 Output: False Explanation: Not all bits are 1. ... Read More
169 Views
Suppose we have a string s of length 2, and also have a list of words w where all words are of length 2. We have to check whether we can concatenate words from w and that concatenated string contains s as substring or not.So, if the input is like s = "no", w = ["ol", "on", "ni", "to"], then the output will be True as we can concatenate strings like "onol", that contains "no"To solve this, we will follow these steps −n := the number of words in wchar_0 := False, char_1 := Falsefor i in range 0 to ... Read More
917 Views
Suppose we have three angles. We have to check whether it is possible to create a triangle of positive area with these angles or not.So, if the input is like a = 40 b = 120 c = 20, then the output will be True as the sum of 40 + 120 + 20 = 180.To solve this, we will follow these steps −if a, b and c are not 0 and (a + b + c) is same as 180, thenif (a + b) >= c or (b + c) >= a or (a + c) >= b, thenreturn ... Read More
531 Views
Suppose we have two lowercase strings s and t. Sometimes, when we type a vowel, the key might get long pressed, and the vowel will be repeated 1 or more times. We have to check whether it is possible that t is typed that indicates s or not.So, if the input is like s = "mine" t = "miiine", then the output will be True as vowel 'i' is repeated three times, other letters are fine.To solve this, we will follow these steps −s_len := size of st_len := size of tj := 0for i in range 0 to s_len ... Read More
447 Views
Suppose we have two strings s and t. We have to check whether s is suffix of t or not.So, if the input is like s = "ate" t = "unfortunate", then the output will be True.To solve this, we will follow these steps −s_len := size of st_len := size of tif s_len > t_len, thenreturn Falsefor i in range 0 to s_len, doif s[s_len - i - 1] is not same as t[t_len - i - 1], thenreturn Falsereturn TrueLet us see the following implementation to get better understanding −Example Live Demodef solve(s, t): s_len = len(s) ... Read More
9K+ Views
Suppose we have a string s. We have to check whether the given string is a palindrome or not. We have to solve this problem using pointers in C.So, if the input is like s = "racecar", then the output will be True.To solve this, we will follow these steps −length := size of stringforward := pointing to the first character of stringreverse := pointing to the last character of stringwhile position of reverse >= position of forward, doif character pointed by reverse is same as character pointed by forward, thenincrease forward and decrease reverse by 1otherwisecome out from loopif ... Read More