Category: Java
-
How to find sum of digits in a number
This is the complete solution to find the sum of digits from a given number using the String class, and a few methods. This solution covers all validations. Regular expressions are also used in this solution for validating the given input.
-
How to find sum of digits in an alpha numeric value
This is the first complete solution to find the sum of digits from a given alpha numeric value by mainly using String and Character class methods along with regular expressions and exceptions.
-
How to reverse each word in a sentence without using reverse method
This is the first complete solution to reverse each word in the given input line of strings. This program uses the core logic to reverse each string. This code now only accepts alphanumeric strings instead of pure integers, symbols and null strings.
-
How to check whether a number is Disarium or not using stream
This is the second solution to check the number for Disarium. This solution uses IntStream, reduce methods of Stream. The Disarium number is say for a given number 351, evaluate the powers from the left side as power (3 * 1) + power (5 * 2) + power (1 *3) , the sum of all…
-
How to find array triplets with sum of two elements equals other element in the same array using stream
This is the third solution to find array triplets, with sum of any two numbers equals with any other element in the same array. This approach uses IntStream, flatMap, filter, mapToObj of Stream.
-
How to find the leader numbers in an array using stream
This is the third solution to find the leader numbers in an array in the reverse direction using stream. An element is leader if it is greater than all the elements to its right side. And the rightmost element is always a leader
-
How to find the triplet numbers from an array whose sum is divisible by 9 using stream
This is the third solution to find the triplets of numbers in which their sum is divisible by 9 from an array of integers. This method uses three nested IntStream to traverse array, add any three numbers come across in each iteration, and then uses simple predicate to verify that the sum is divisible by…
-
How to find the pairs of numbers from an array whose sum is divisible by 9 using stream
This is the third solution to find the pairs of numbers in which their sum is divisible by 9 from an array of integers. This method uses nested IntStreams to traverse the array , add any two numbers come across in each iteration, and then uses a simple predicate to verify that the sum is…
-
How to find Missing Prime numbers from any given sequence of integers using Stream
This is the second solution to find the missing prime numbers from any given sequence of integers. This solution uses the Lambda expression with single abstract method. The solution also uses the range, filter, foreach methods of IntStream.
