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 1422 of 2650
144 Views
We are given a number N and another number L. The goal is to find the numbers between 1 and N that have a difference between the number itself and the sum of its digits is not less than L.If N=23, L=10 then the count of such numbers will be 4.23-(2+3)=18, 22-(2+2)=18, 21-(2+1)=18, 20-(2+0)=18.All above numbers meet the conditionBut 19-(1+9)=9 which is less than L, similarly 18, 17….1.Let us understand with examplesInput − N=30 L=19Output − Count of Numbers such that difference between the number and sum of its digits not less than L are − 1Explanation − Only 30 ... Read More
259 Views
We are given multiple sentences in the form of strings. The goal is to count the number of words that exist in all of the sentences.Note − words containing all lowercase letters will be considered onlyIf sentences are −“ I am learning C language ”“ learning new things is easy ““ Kids are learning healthy habits “Only “learning” exists in all three. So count is 1.Let us understand with examplesInput − “The clothes were dry”, “All the kids were playing”, “Those were the best days”Output − Count of words that are present in all the given sentences are − 2Explanation ... Read More
164 Views
We are given an array arr[] containing integer elements. The goal is to find the count of pairs that can be formed by elements of sub-arrays of arr[] such that each subarray has only distinct elements. If the array is [ 1, 2, 2, 3, 3 ] then subarrays with distinct elements only will be [ 1, 2 ] and [ 2, 3 ]. And pairs will be (1, 2) and (2, 3) hence count of pairs is 2.Let us understand with examplesInput − arr[] = {1, 2, 5, 3 }Output − Count of pairs formed by distinct element sub-arrays ... Read More
213 Views
We are given two variables n and m representing the number of points on a 2D plane. Out of n points, m points are collinear. The goal is to find the number of triangles that can be formed using these n points.Collinear points − The points that lie on the same line are called collinear. Points A and B are collinear.Given n=4 (A, B, C, D ) , m=2 (A, B)Number of triangles −Choosing any three points out of 4 = 4C3But collinear points cannot form triangle so remove possible triangles that will be counted above = 2C3Total triangles= 4C3 ... Read More
770 Views
We are given a string str[] as input. The goal is to count the number of anagram substrings present in str[]. Two strings are anagrams of each other if they contain the same number of characters and all characters occur in both. The order of characters can be different.“abc” is an anagram of “cba”, “bca” etc.Let us understand with examples.Input − str[] = “abccb”Output − Count of total anagram substrings are − 4Explanation − Anagrams are − (b, b), (c, c), (bc, cb), (bcc, ccb)Input − str = “aaa”Output − Count of total anagram substrings are − 4Explanation − Anagrams ... Read More
172 Views
We are given a target array arr[] containing positive integers. The goal is to construct the target array arr[] using an initial array with all 0s. The operations that can be applied on a given empty array with all 0s will suffix increment/decrement operations.If we choose any index say i, then in case of suffix increment operation we will add 1 to all elements from index i till last index.In case of suffix decrement operation we will subtract 1 from all elements from index i till last index.Let us understand with examplesInput − arr[]= { 1, 2, 3 }Output − ... Read More
462 Views
Suppose we have a list of requests where each list contains elements like [uid, time_sec] (uid is the user id and time_sec is the timestamp). This indicates the user whose id is uid has requested to a website at timestamp time_sec. We also have two values u and g where u denotes maximum number of requests that are allowed in any < 60 second frame for a given uid and g is the maximum number of requests that are allowed in any < 60 second frame globally. Now if we want to process each request one by one and rate ... Read More
228 Views
Suppose we have a 2d matrix. We have to check whether we can start from some cell then move adjacent cells (up, down, left, right) of the same value, and come back to the same starting point. We cannot revisit a cell that we have visited last.So, if the input is like222121212221then the output will be True, as we can follow 2s to form a cycle.To solve this, we will follow these steps −R := row count of matrixC := column count of matrixvis := make a matrix of size R x C and fill with FalseDefine a function dfs() ... Read More
229 Views
Suppose we have a binary matrix and another value k. You want to split the matrix into k pieces such that each piece contains at least one 1 in it. But there are some rules for cutting, we have to follow in order: 1. Select a direction: vertical or horizontal 2. Select an index in the matrix to cut into two sections. 3. If we cut vertically, we can no longer cut the left part but can only continue cutting the right part. 4. If we cut horizontally, we can no longer cut the top part and can only continue ... Read More
609 Views
Suppose we have a string s, we have to check whether we can make this string a palindrome after deleting at most k characters or not.So, if the input is like s = "lieuvrel", k = 4, then the output will be True, we can delete three characters to get palindrome "level".To solve this, we will follow these steps −Define a function lcs() . This will take a, bm := size of a, n := size of btable := matrix of size (m + 1) x (n + 1) and fill with 0for i in range 1 to m, dofor ... Read More