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 1940 of 2650
4K+ Views
Suppose, we have a date in the format “YYYY-MM-DD”. We have to return the day number of the year. So if the date is “2019-02-10”, then this is 41st day of the year.To solve this, we will follow these steps −Suppose D is an array of day count like [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]Convert the date into list of year, month and dayif the year is leap year then set date D[2] = 29Add up the day count up to the month mm – 1. and day count after that.ExampleLet us see ... Read More
277 Views
In this problem, we are given an mXn 2D matrix and we have to print all possible paths from top left to bottom right of matrix. For traversal, we can move in all four directions i.e. left, right, top, bottom.Thought the moves right and top are rarely used but these can be beneficial sometimes.Let’s take an example to understand the topic better :Input:1 3 5 2 8 9Output:1 -> 3 -> 5 -> 9 1 -> 3 -> 8 -> 9 1 -> 2 -> 8 -> 9To solve this problem, we will move from one cell to other ... Read More
771 Views
Suppose we have two arrays arr1 and arr2, the elements of arr2 are unique, and all elements in arr2 are also present in arr1. We have to sort the elements of arr1 in such a way that the relative ordering of items in arr1 are the same as in arr2. If there are some elements that are not present in arr2, they should be placed at the end of arr1 in ascending order. So if the arr1 is like [2, 3, 1, 3, 2, 4, 6, 7, 9, 2, 19], and arr2 is like [2, 1, 4, 3, 9, 6], ... Read More
1K+ Views
Suppose we want to distribute some number of candies to a row of n people in the following way −We then give 1 candy to the first people, 2 candies to the second people, and so on until we give n candies to the last people.After that, we go back to the start of the row again, give n + 1 candies to the first people, n + 2 candies to the second people, and so on until we give 2 * n candies to the last people.We will repeat this process until we run out of candies. The last ... Read More
550 Views
In this problem, we are given a string of length n and we have to print all permutations of the characters of the string in sorted order.Let’s take an example to understand the problem :Input: ‘XYZ’Output: XYZ, XZY, YXZ, YZX, ZXY, ZYX.Here we have to print all permutations in lexicographical order (alphabetically increasing order).To solve this problem, we have to first sort the array in alphabetically increasing order, the sorted array is the first element of the permutation. And then generate the next higher order permutation of the string.The below code will make the solution more clear to you :Example Live ... Read More
177 Views
Suppose there are words given. These are first and second, consider occurrences in some text of the form "first second third", here second comes immediately after the first, and third comes immediately after the second.For each such cases, add "third" into the answer, and show the answer. So if the text is like “lina is a good girl she is a good singer”, first = “a”, second = “good”, the answer will be [girl, singer]To solve this, we will follow these steps −text := split the string by spacesres is an empty listfor i := 0 to size of text ... Read More
1K+ Views
In this problem, we are given a string of n characters and we have to print all permutations of characters of the string. Repeating of characters of the string is allowed. The printing of permutation should be done in alphabetical order (lexicographically sorted order).Let’s take an example to understand the topic better :Input − XYOutput − XX, XY, YX, YYTo solve this problem, we need to use fix and recur logic. Here, we will fix one element at first index of the array and then recursively call for the next elements in the sequence.Let’s see an implementation example which will ... Read More
386 Views
This article is intended to print a half-pyramid pattern bash using the C++ programming language. In the view of the stipulated pattern to be printed, the following algorithm is being orchestrated to achieve our goal as;AlgorithmStep-1 Set the length of the Bash (Height) Step-2 Outer loop to handle the number of rows Step-3 Inner loop to handle columns Step-4 Print the pattern with the character (@) Step-5 Set the pointer to a new line after each row (outside the inner loop) Step-6 Repeat the loop till the Bash HeightExampleSo, the following C++ source code is ultimately carved out by complying ... Read More
323 Views
This article prints an interesting pattern using C++ programming. Here is the algorithm as followingAlgorithmStep-1 Define the size which will be double automatically Step-2 Print the upper section using a loop Step-3 Print the lower section using a loopExampleBased on the above algorithm, the following c++ code is carved out as; Live Demo#include using namespace std; int main(){ int n=3; int i,j; // This is upper half of pattern for (i=1; i