## Get the Sum of Digits in a number till it become a single digit

Objective – Given a number, Write a program to get the sum of digits in a number till it become a single digit. Example: N = 999 -> 9+9+9 = 27-> 2+7 = 9...

@tutorialhorizon

Objective – Given a number, Write a program to get the sum of digits in a number till it become a single digit. Example: N = 999 -> 9+9+9 = 27-> 2+7 = 9...

Objective: Given a number, write a program to check if the number is prime or not. Prime Number: A number is called a prime number when number is not divisible by 1 or by...

Objective: Given a number N, write a program to print first N prime numbers. What is Prime number:?? A prime number (or a prime) is a natural number greater than 1 that cannot be...

Objective– Given two strings, find out if they are equal or not without using any built-in function (without using equals() function in java). Example: String x=’tutorial’ and String y=’tutorial’ are equal – true String...

Objective: Given a String, remove all the vowels from the string. What Are Vowels? The letters A, E, I, O, and U are called vowels. The other letters in the alphabet are called consonants....

Earlier we have seen the basics of Dijkstra algorithm. In this article we will see its implementation using adjacency list and Min Heap. We strongly recommend reading the following articles Dijkstra algorithm and how...

Objective– Given two numbers, swap both the numbers using XOR operators. Example: X = 4, Y = 8 Output: X = 8, Y= 4 Approach: XOR operator There are many ways to swap two...

Objective: Given a string, write an algorithm to replace all the vowels with next consonant, and if last alphabet is vowel, remove it. Example: String input: “abcdefg” Output: “bbcdffg” String input: “aaaabccceee” Output: “bbbbbccc”...

Objective: Given a number convert it to base 3 representation. Example: N = 35 Base 3 representation: 1022 N = 50 Base 3 representation: 1212 Approach: Till the number is greater than 0, keep...

Objective: Given a graph, check if the graph contains a cycle using disjoint set. Note: Disjoint-set data structure, also called a union–find data structure or merge–find set. Example: Earlier in Detect Cycle in Undirected Graph using DFS we...

Objective: Given a graph, source vertex and destination vertex. Write an algorithm to count all possible paths between source and destination. Condition: Graph does not contain any cycle. This problem also known as “paths...

Objective: Given a directed graph write an algorithm to find out whether graph contains cycle or not. Example: Approach: Graph contains cycle if there are any back edges. There are two types of back...

Objective: Given undirected graph write an algorithm to find out whether graph contains cycle or not. Example: Approach: Earlier we have seen how to find cycles in directed graphs. In this article we will...

Objective: Given a list of software’s which you need to install in a computer. Few software’s has dependency on other software’s in the list, means these software can be installed only when all of...

%d bloggers like this: