Java Program to Find the Sum and Product of Elements in a Row/Column

This is the Java Program to Find the Sum and Product of Elements in a Row/Column. Problem Description Given a square matrix, print the sum and product of the elements in each row and column. Example: Matrix: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Output: Sum … Read more

advertisement

Java Program to Find the First Capital Letter/Small Letter/Vowel/Consonant/Number/White Space/Special Character in a Given String

This is the Java Program to Find the First Capital Letter/Small Letter/Vowel/Consonant/Number/White Space/Special Character in a Given String. Problem Description Given a string, find the first position of the capital letter, small letter, vowel, consonant, whitespace, and special character if present in the string. Example: String x = “Ac @” Output = Capital letter = … Read more

advertisement

Java Program to Solve the passing Car Codility Problem

This is the Java Program to Solve the passing Car Codility Problem. Problem Description Given a boolean array of 0’s and 1’s, where 0’s represent cars going to east and 1’s represent cars going to the west. Find out the pairs of the cars that will cross each other, that is, the pairs of cars … Read more

advertisement

Java Program to Find the Length of the Longest Repeating Sub-sequence in a String

This is the Java Program to Find the Length of the Longest Repeating Sub-sequence in a String. Problem Description Given a string s, find and print the length of the longest repeating subsequence in the string, that is, the length of the subsequence consisting of some of the characters in the original string, which are … Read more

advertisement

Java Program to Solve the Dutch National Flag Problem

This is the Java Program to Solve the Dutch National Flag Problem. Problem Description Given an array of 0’s, 1’s and 2’s, all the elements in the random order, sort the array in linear time, without using extra space. This is known as the Dutch National Flag problem. Example: Array = [1 0 2 2 … Read more

advertisement

Java Program to Replace the Element with its Next Greatest Element, Rightmost Element will be Replaced by 0

This is the Java Program to Replace the Element with its Next Greatest Element, Rightmost Element will be Replaced by 0. Problem Description Given an array of integers, replace each element of the array with the greatest element present on the right side of the element, in the array. The rightmost element or the last … Read more

advertisement

Java Program to Find the Smallest Positive Integer Missing in an Unsorted Integer Array

This is the Java Program to Find the Smallest Positive Integer Missing in an Unsorted Integer Array. Problem Description Given an array of integers, find out the smallest positive integer missing from the array. Example: Array = [-1, -3, 3, 2, 8 ,6] Output: 1. Problem Solution First sort the array. Then initialize a variable … Read more

advertisement

Java Program to Convert a String to an Integer Array

This is the Java Program to Convert a String to an Integer Array. Problem Description Given a string consisting of various numbers separated by spaces, convert it into an array of Integers, such that every number occupies a position in the array, and for every invalid number, there is a -1 in the array. Example: … Read more

advertisement

Java Program to Reverse a String Word by Word in Place

This is the Java Program to Reverse a String Word by Word in Place Problem Description Given a string, reverse each word in its place, where words are separated by whitespace. Example: String x = “We belong to Russia” Output = “eW gnoleb ot aissuR” Problem Solution Split the given string into various substrings, whenever … Read more

advertisement

Java Program to Print Elements Which Occur Odd Number of Times

This is the Java Program to Print Elements Which Occur Odd Number of Times. Problem Description Given an array of integers, print all the elements whose frequency are odd. Example: Array = [5, 4, 4, 2, 1] Output: 5 2 1. Problem Solution Iterate through the array, and for every element, count its frequency in … Read more

advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter