
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

323 Views
Suppose we have an integer array, we need to find one continuous subarray such that, if we only sort that subarray in ascending order, then the whole array will be sorted too. We need to find the shortest such subarray and output its length. So if the array is [2, 6, 4, 8, 10, 9, 15], then the output will be 5. The array will be [6, 4, 8, 10, 9]To solve this, we will follow these steps −res := sort the nums as an arrayans := 0set r as a linked listfor i in range 0 to the length ... Read More

269 Views
Suppose we have given a binary tree in which each node holds an integer key. We have to find the paths that sum to a given value. The path should start from root to leaf. We have to find the path where the sum is same.If the tree is like [5, 4, 8, 11, null, 13, 4, 7, 2, null, null, 5, 1], and sum is 22, then it will be −The paths are [[5, 4, 11, 2], [5, 8, 4, 5]].To solve this, we will follow these steps −Use the dfs function to solve this problem, the dfs is ... Read More

2K+ Views
Suppose we have a linked list. We have to check whether the list elements are forming a palindrome or not. So if the list element is like [1, 2, 3, 2, 1], then this is a palindrome.To solve this, we will follow these steps −fast := head, slow := head, rev := None and flag := 1if the head is empty, then return truewhile fast and next of fast is availableif next of the next of fast is available, then set flag := 0 and break the loopfast := next of the next of fasttemp := slow, slow := next ... Read More

15K+ Views
Monolithic architecture is built as one large system and is usually one code-base. Monolithic application is tightly coupled and entangled as the application evolves, making it difficult to isolate services for purposes such as independent scaling or code maintainability.It extremely difficult to change technology or language or framework because everything is tightly coupled and depend on each other.Microservices architecture is built as small independent module based on business functionality. In microservices application, each project and services are independent from each other at the code level. Therefore it is easy to configure and deploy completely and also easy to scale based ... Read More

118 Views
In this problem, we are given a sorting algorithm and a number n. Our task is to print an array of n elements that could not be sorted by the algorithm. i.e the algorithm will fail.Algorithmloop i from 1 to n-1 loop j from i to n-1 if a[j]>a[i+1] swap(a[i], a[j+1])Let’s look into this sorting algorithm, it is using two nested loops. The outer one will start from 1 to n-1 and inner one from i to n-1, and will check the value of inner loop element and outer loop elements at each iteration and ... Read More

142 Views
In this problem, we are given a string. Our task is to print a string that is closest to the current string and does not contain any adjacent duplicate characters.Let’s take an example to understand the problemInput: string = “good” Output: goadIn this example, we found that the elements at index 1 and 2 are the same, so we change the elements at index 2.To solve this problem, we will traverse the string and check if any two adjacent elements have are same. If yes, then change the second element (if i and i+1 elements are the same, change i+1 ... Read More

903 Views
In this problem, we are given a 2-dimensional matrix. And our task is to print the elements of the matrix in a counter-clockwise spiral from.Counterclockwise Spiral Form − It is a spiral traversal which starts from top-left and the goes in the counter-clockwise direction to first bottom-right-up-left.The counter-clockwise traversal will be 1 5 9 13 14 15 16 12 8 4 3 2 6 10 11 7.Let’s take an example to understand the problemInput: 2 4 6 1 7 9 5 0 3 Output: 2 1 5 0 3 9 7To solve this problem, we will be ... Read More

447 Views
In this problem, we are given a 2-dimensional matrix. Our task is to print all the elements of the matrix in reverse spiral form.Let’s take an example to understand the problemInput: 12 23 54 67 76 90 01 51 43 18 49 5 31 91 75 9 Output: 18 49 1 90 76 43 31 91 75 9 5 51 67 54 23 12We will start from the center of the matrix and print elements in reverse spiral direction taking four loops for printing elements in reverse direction.ExampleProgram to show the implementation of our solution Live Demo#include ... Read More

723 Views
In this problem, we are given a 2-dimensional matrix. Our task is to print the zigzag form of the matrix.Let’s take an example to understand the problemInput: 12 99 43 10 82 50 15 75 5 Output: 12 99 43 50 82 10 15 75 5To solve this problem, we will print the elements of the array in both directions (LtoR and RtoL). And change the direction using the flag variable.Example Live Demo#include using namespace std; void printZigZagPattern(int row, int col, int a[][5]) { int evenRow = 0; int oddRow = 1; while (evenRow

208 Views
In this problem, we are a 2d matrix and a point P(c, r). Our task is to print all elements of the matrix in a spiral form (anti-clockwise) that starts from a given point P.Let’s take an example to understand our problem, Input: matrix[][] = {{3, 5, 7} } Output:To solve this problem, we use 4 loops for printing elements. Each loop prints elements of its own direction. We will start our printing from point p and go on printing the spiral form.ExampleProgram to show the implementation of our solution Live Demo#include using namespace std; const int MAX = 100; ... Read More