
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 26504 Articles for Server Side Programming

7K+ Views
In this article, you will learn about the approaches to find the number of substrings (non-empty) that you can form in a given string.Input : string = “moon” Output : 10 Explanation: Substrings are ‘m’, ‘o’, ‘o’, ‘n’, ‘mo’, ‘oo’, ‘on’, ‘moo’, ‘oon’ and ‘moon’. Input : string = “yellow” Output : 21Approach to find The SolutionLet the length of the string be n, so looking at the example above, we understand that to find all possible numbers of substrings, we need to add substrings of length n, (n-1), (n-2), (n-3), (n-4), ......2, 1.Total number of substrings = n ... Read More

308 Views
To find the probability of numbers’ parity, i.e., is it even or odd, and for the given ranges. For each query, we need to print p and q representing the probability by p / q, for example.Input : N = 5, arr[] = { 6, 5, 2, 1, 7 } query 1: 0 2 2 query 2: 1 2 5 query 3: 0 1 4 Output : 0 3 4 1 2In this problem, we will maintain two arrays containing the number of odd and even numbers present until that index. This simplifies our problems, and now we need ... Read More

355 Views
In this problem we are given a binary tree and we are required to perform dfs from a particular node in which we assume the given node as the root and perform dfs from it.In the above tree suppose we are required to perform DFS from node FIn this tutorial we are going to apply some unorthodox methods so that it will decrease our time complexity substantially and thus we will be able to run this code for higher constraints also.Approach − In this approach we are not simply going to go the naive way i.e. where we simply apply ... Read More

246 Views
Given n, r, k, now we have to find how we can select r things from n so that specific k things always occur together, for example.Input : n = 8, r = 5, k = 2 Output : 960 Input : n = 6, r = 2, k = 2 Output : 2We need a little knowledge for this problem because this problem is asking us to find the permutation of n and r such that k things come together.Approach to Find the SolutionWe need to formulate our formula for this question, and that will ... Read More

1K+ Views
A permutation of a string is formed when the character of the given strings are rearranged in any form. In this tutorial, we are going to discuss how we can print all the permutations of a given string using C++’s Standard Template Library, for exampleInput : s = “ADT” Output : “ADT”, “ATD”, “DAT”, “DTA”, “TAD”, “TDA” Explanation : In the given output as you can see all the string are made up of same three character present in our string and are just rearranged thus they fit in the definition of a permutation of a string now ... Read More

172 Views
Two arrays, A and B, are given to us in this tutorial. For example, we need to output any permutation of A so that the indices for which A[ I ] > B[ I ] are maximized, for exampleInput: A = [12, 22, 41, 13], B = [1, 20, 10, 12] Output: 12, 22, 41, 13 Input: A = [2, 5, 9, 7], B = [1, 12, 4, 54] Output: 2 7 5 9 Multiple answers can be present in that case we are simply going to print any one of the answers.In this problem, we need to ... Read More

216 Views
Varignon’s Parallelogram is formed by joining midpoints of each side of a quadrilateral. Let’s say we have a quadrilateral ABCD. The midpoints of each side are P, Q, R, and S. If we connect all the midpoints, it will always form a parallelogram PQRS known as Varignon’s Parallelogram.In this tutorial, we will discuss how to find the perimeter and area of Varignon’s Parallelogram with the given two diagonals and the area of a quadrilateral, for example −Input: d1 = 6, d2 = 9, Area = 12 Output: Perimeter = 15 Area = 6 Input: d1 = 11, d2 = ... Read More

183 Views
A pentatope number is described as the fifth number in the pascal’s triangle. Now, as you know, it’s the fifth number, so it means that we need to have at least five numbers in the pascal’s triangle, so this series’ first number starts from 1 4 6 4 1 the fourth row of pascal’s triangle. So, In this given tutorial, we are required to find the nth pentatope number, for exampleInput : 1 Output : 1 Input : 4 Output : 35 You can check the output from the following diagram −Now for this problem, as ... Read More

189 Views
Given a 2 D matrix in this problem, and we need to find the paths having maximum average value. For the path, our source is the topmost left cell, and the destination is the bottommost right cell, for example −Input : Matrix = [1, 2, 3 4, 5, 6 7, 8, 9] Output : 5.8 Path with maximum average is, 1 -> 4 -> 7 -> 8 -> 9 Sum of the path is 29 and average is 29/5 = 5.8In this problem, we are allowed to move only right or downwards. This makes our problem easier as we know ... Read More

223 Views
To solve a problem in which we are given a binary tree. Now we need to find the path having the maximum number of bends. i.e., A bend is considered when the direction of the path changes from left to right or vice versa, for exampleInput −Output −6Now in this approach, we will traverse through the tree and keep track of previous movements. If the direction changes, we simply update our bends count, and then we find the maximum.Approach to Find the SolutionIn this approach, we will traverse through all the paths, and we find the maximum number of bends ... Read More