
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

533 Views
Suppose we have a string s as S-expression. We have to evaluate that S-expression and return result as integer. As we know that the s-expression is an expression which is either one number, or a recursive expression wrapped in parentheses like (+ (- 3 2) (* 3 3)), which indicates (3 - 2) + (3 * 3) = 10. Here valid operators are +, -, *, and /.So, if the input is like s = "(- (+ 3 2) 2)", then the output will be 3, as ((3 + 2) - 2) = 3.To solve this, we will follow these ... Read More

255 Views
In this problem, we are given an array arr[] of size N and Q queries which can be of two types. Our task is to create a program to solve the queries to update a given index and find GCD in the range.Queries are −Type 1 − {1, index, value} - increase the element at given index by value.Type 2 − {2, L, R} - find the GCD of elements in the index range [L, R].Problem Description − We need to find the GCD of the elements that are in the range [L, R] and return the value.Let’s take an ... Read More

196 Views
Suppose we have two lowercase strings s and t. Now consider an operation where we replace all occurrences of a character in s with another character. If we can perform this operation any number of times, we have to check whether s can be converted to t or not.So, if the input is like s = "eye" t = "pip", then the output will be True, as we can replace "e"s with "p"s then "y" by "i".To solve this, we will follow these steps −Define one map m1 and another map m2n := size of sfor initialize i := 0, ... Read More

266 Views
Suppose we have a list of numbers called nums. Now let us consider an operation where we delete some sublist which is a palindrome. We have to find the minimum number of operations required such that the list is empty.So, if the input is like nums = [6, 2, 4, 4, 2, 10, 6], then the output will be 2, as we can remove the sublist [2, 4, 4, 2] first then the list is like [6, 10, 6] this is also a palindrome, so remove it to make list empty.To solve this, we will follow these steps −Define an ... Read More

128 Views
In this problem, we are given an array arr[] of size n and Q queries each consisting of 2 values L and R. Our task is to create a program to solve queries to return the absolute difference between L-th smallest number and the R-th smallest number.Problem Description − To solve each query, we need to find the index of Lth smallest and Rth smallest number. And find the difference between these indices.Let’s take an example to understand the problem, Inputarr[] = {8, 4, 1, 5, 2} Q = 2 Queries[][] = {{2, 4}, {1, 5}}Output1 2ExplanationFor {2, 4}: 2nd ... Read More

571 Views
Suppose we have a string s and a regular expression pattern. We have to check whether the given pattern matches with given string or not. In the regular expression, there are few rules −. (period) which matches any single character* (asterisk) which matches zero or more of the preceding element.So, if the input is like pattern = "h.l*o" s = "hello", then the output will be True, as We have ra and then a single characterTo solve this, we will follow these steps −n := size of sm := size of pDefine a function dp() . This will take i, ... Read More

510 Views
In this problem, we are given string str, Q number of queries each consisting of two values L and R for substring[L...R]. Our task is to create a program to solve Queries to check if substring[L…R] is palindrome or not.Problem Description − For solving each query, we need to check whether the substring created within the range L to R is a palindrome or not.Let’s take an example to understand the problem, Inputstr = “abccbeba” , Q = 3 Query[][] = {{1, 4}, {0, 6}, {4, 6}}OutputPalindrome Not Palindrome PalindromeExplanationCreating all substring for the given substrings : Substring[1...4] = “bccb”, ... Read More

183 Views
Suppose we have a 2d binary matrix, we have to find the total number of submatrices with all 1 s.So, if the input is like110110001then the output will be 10, as there five 1 x 1 matrix, two 2 x 1 matrix. two 1 x 2 matrices. And one 2 x 2 matrix.To solve this, we will follow these steps −Define a function getAns(), this will take an array a, ret := 0n := size of aDefine an array v of size nDefine one stack stfor initialize i := 0, when i < size of a, update (increase i by ... Read More

116 Views
In this problem, we are given a number n that denotes n boxes that lie on the edge of a circle. And there are Q queries each consisting of two integers, a and b. Our task is to create a program to solve queries to check if it is possible to join boxes in a circles.Problem Description − To solve each query, we need to check the possibility of connecting box a and box b by a rod in such a way that the intersection of boxes from the last query cannot be disturbed. We need to print possible or ... Read More

355 Views
Suppose we have a list of edges in the form (u, v) and these are representing a tree. For each edge we have to find the total number of unique paths that includes said edge, in the same order as given in the input.So, if the input is like edges = [[0, 1], [0, 2], [1, 3], [1, 4]]then the output will be [6, 4, 4, 4].To solve this, we will follow these steps −adj := adjacency list from given edgescount := an empty mapDefine a function dfs() . This will take x, parentcount[x] := 1for each nb in adj[x], ... Read More