
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

438 Views
In this problem, we are given a string str consisting of character and alphabets only. Our task is to find the longest length number in a string. Problem Description: we need to find the length of the number i.e. consecutive numerical characters in the string.Let’s take an example to understand the problem, Input: str = “code001tutorials34124point”Output: 34124Explanation: Numbers in the string are001 - size 334124 - size 5Solution ApproachA simple solution to the problem is by traversing the sting and finding the number’s length and its starting index. We will store the starting position and count of characters in the string for each number ... Read More

860 Views
In this problem, we are given a string str consisting of english alphabets. Our task is to find the letter's position in the Alphabet using the Bit operation. Problem Description: Here, we will return the position of each character of the string as it is in english alphabets.The characters of the string are case-insensitive i.e. “t” and “T” are treated the same.Let’s take an example to understand the problem, Input: str = “Tutorialspoint”Output: 20 21 20 15 18 9 1 12 19 16 15 9 14 20 Solution ApproachA simple solution to find a character's position is by finding its logical AND operation with 31.Program ... Read More

629 Views
In this problem, we are given a 2-D matrix of size nXm consisting of 0’s and 1’s only. Our task is to find the length of the largest region in the Boolean Matrix. Problem Description: If a cell contains 1, it is a filled Cell. We need to find the length of connected cells which are connected adjacent to each other horizontally or vertically or diagonally. Let’s take an example to understand the problem, Input: matrix[4][5]{ {0, 1, 1, 0, 1}, {0, 0, 1, 1, 1}, {1, 0, 0, 0, 0}, {1, 0, 1, 0, 1} }Output: 6Explanation: The number of connected filled ... Read More

510 Views
In this problem, we are given a linked list that might contain loops. Our task is to find the length of the loop in the linked list. Problem Description: we need to count the number of nodes in the loop if it contains a loop otherwise return -1.Let’s take an example to understand the problem, Input: linked-list :Output: 8Solution ApproachTo solve the problem, we first need to check whether the linked list contains a loop. An approach to check this is using Floyd’s Cycle Finding Algorithm. In Floyd’s Cycle Finding Algorithm, we will traverse the linked list using two pointers. One slowPointer that increases by 1 ... Read More

208 Views
In this problem, we are given an integer n denoting the length of the side of a regular hexagon. Our task is to Find length of Diagonal of Hexagon.Problem Description: Here, we have the side of a regular hexagon. And we need to find the length of the diagonal of the hexagon.Let’s take an example to understand the problem, Input: a = 7Output: 12.11Solution ApproachTo solve the problem and find the length of diagonal which is given by the mathematical formula, Diagonal = 1.73 * aLet’s derive the formula, Here, we have a regular polygon of length a.The angle between the diagonal and ... Read More

278 Views
In this problem, we are given a number N. Our task is to find the last five digits of a given five digit number raised to power five. Let’s take an example to understand the problem, Input: N = 25211Output:Solution ApproachTo solve the problem, we need to find only the last five digits of the resultant value. So, we will find the last digit of the number after every power increment by finding the 5 digit remainder of the number. At last return the last 5 digits after power of 5.Program to illustrate the working of our solution, ExampleLive Demo#include using ... Read More

1K+ Views
In this problem, we are given two numbers a and b. Our task is to find Last Digit of a^b for Large Numbers. Let’s take an example to understand the problem, Input: a = 4 b = 124Output: 6Explanation: The value of a^b is 4.523128486 * 1074Solution ApproachThe solution to the problem is based on the fact that all the exponents of a number will be repeated after 4 exponent values.So, we will find the value of b%4. Also, for any base value, the last digit of its power is decided by the last digit of the base value.So, the resultant value will be ... Read More

209 Views
In this problem, we are given an integer n. Our task is to find the largest sum of digits in all divisors of n. Problem Description: Here, we will find the divisor of the number n whose sum of digits in largest.Let’s take an example to understand the problem, Input: 18Output: 9Explanation: All divisors of 18 are 1, 2, 3, 6, 9, 18.The maximum digits sum is 9.Solution ApproachFind all divisors of the number N. And then find the sum of digits of each divisors and then return the value with the largest sum.Program to illustrate the working of our solution, ExampleLive Demo#include using ... Read More

397 Views
In this problem, we are given a binary tree. Our task is to find the largest subtree sum in a tree. Problem Description: The binary tree consists of positive as well as negative values. And we need to find the subtree that has the maximum sum of nodes.Let’s take an example to understand the problem, Output: 13Explanation: The sum of left-subtree is 7The sum of right-subtree is 1The sum of tree is 13Solution ApproachTo solve the problem, we will do the post-order traversal. Calculate sum of nodes left subtree and right subtree. For current node, check if the sum of nodes of current node ... Read More

310 Views
In this problem, we are given a string N that represents a number. Our task is to find the largest number smaller than N with the same set of digits. Problem Description: we need to find a number using all the digits of the given number which is the largest smaller number than N.Let’s take an example to understand the problem, Input: N = “54314”Output: 54341Solution ApproachA simple solution to the problem is by finding the digit of the number which can be moved to find the largest smaller number. Now, the number should be greater than its right success in order to solve ... Read More