
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

207 Views
Suppose we have a rows x cols screen and a sentence represented by a list of non-empty words, so we have to find how many times the given sentence can be fitted on the screen. There are certain properties −A word will not be split into two lines.The order of words in the sentence must not be changed.There will be only one space between two words.The total number of words in the sentence won't exceed 100.The length of each word is greater than 0 but less than 10.1 ≤ rows, cols ≤ 20, 000.So if the input is like rows ... Read More

309 Views
Suppose we have a sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same. So for example, these are arithmetic sequence: [1, 3, 5, 7, 9], [7, 7, 7, 7], [3, -1, -5, -9], But the following sequence is not arithmetic. [1, 1, 2, 5, 7]Now a zero-indexed array A consisting of N numbers is given. A slice of that given array is any pair of integers (P, Q) such that 0

737 Views
Suppose we have a non-negative integer num that is represented as a string, we have to remove k digits from the number so that the new number is the smallest possible. So if the input is like “1432219” and k = 3, then the result will be “1219”.To solve this, we will follow these steps −Define a stack st, create an empty string retn := size of numfor i in range 0 to n – 1while k is non zero and stack is not empty and top of stack > num[i]delete from the stack and decrease k by 1insert num[i] ... Read More

1K+ Views
Suppose we have one infinite integer sequence, we have to find the nth digit of this sequence. So if the input is 11, then the output will be 0 as if we place the numbers like 123456789101112, so the 11th digit is 0.To solve this, we will follow these steps −len := 0 and cnt := 9 and start := 1while n > len * cntn := n – (len * cnt)cnt := cnt * 10, start := start * 10increase len by 1start := start +(n - 1) / lens := start as stringreturn s[(n – 1) mod len]Example ... Read More

6K+ Views
In this article, we have a string. Our task is to reverse the words in the given string. Here is an example of reversing the words of a string: Example The example below reverses the words of the given string: Input: "I am Viper" Output: Viper am I Here are the approaches to reverse the words of a string: Using Two Pointer Approach Using STL reverse() Function Using stringstream with Vector Using Recursive Approach ... Read More

192 Views
Suppose we have a singly linked list where elements are sorted in ascending order, we have to convert it to a height balanced BST. So if the list is like [-10, -3, 0, 5, 9], The possible tree will be like −To solve this, we will follow these steps −If the list is empty, then return nullDefine a recursive method called sortedListToBST() this will take list start nodex := address of the previous node of mid node from list amid := exact mid nodecreate a new node with value by taking from the value of midnextStart := next of mid ... Read More

616 Views
In this article, we will understand the four divisors problem. We have an array of integers, and our task is to find the sum of divisors of the array elements that have exactly four divisors. If there is no such integer in the array, then return 0. Here is a detailed example given below: Example The following example implements four divisors sum problem: Input: arr = [5, 10, 15, 8] Output: 57 The explanation of the above example is as follows: Divisors of 5 = (1, 5) => count != ... Read More

246 Views
As we know that the power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps −if x is even then x = x / 2if x is odd then x = 3 * x + 1So for example, the power of x = 3 is 7 because 3 uses 7 steps to become 1 (3 → 10 → 5 → 16 → 8 → 4 → 2 → 1). So if we have some integers lo, hi and k. We have to sort all integers in the interval ... Read More

3K+ Views
In this article, we have a binary search tree and our task is to balance the given binary search tree. A binary search tree is a tree data structure and a special type of binary tree that follows the conditions given below: The left child node's value is always less than the parent node. The right child node has a greater value than the parent node. All the nodes individually form a binary search tree. The inorder traversal of nodes in BST are ... Read More

664 Views
Suppose we want to design a stack that supports the following operations.CustomStack(int maxSize) This initializes the object with maxSize which is the maximum number of elements in the stack or do nothing if the stack reached the maxSize.void push(int x) This inserts x to the top of the stack if the stack hasn't reached the maxSize.int pop() This deletes and returns the top of stack or -1 if the stack is empty.void inc(int k, int val) This increments the bottom k elements of the stack by val. If there are less than k elements in the stack, just increment all ... Read More