Java Program to Remove Characters from the Input String which are Present in the Mask String

This is the Java Program to Remove Characters that belong to a Mask String from the Input String Problem Description Given a string of characters and a mask string remove all the characters of the mask string from the first string. Example: String x = “We belong to Russia” Mask = “Wbos” Output = “e … Read more

advertisement

Java Program to Find the First Non-repeated Character in a String

This is the Java Program to Find the First non-repeated Character in a String Problem Description Given a string of characters, find the first non-repeated character in the string. Example: String x = “Hi this is Marry” Output = ‘H’ Problem Solution Make two new arrays to store the frequency of each character and the … Read more

advertisement

Java Program to Print the Longest Decreasing Subarray

This is the Java Program to Print the Longest Sub-Array that is decreasing. Problem Description Given an array of integers, find the longest contiguous subarray whose elements are decreasing, that is, the elements following the preceding elements in the subarray must be smaller than them. Example: Array = [5, 6, 3, 0, 7, 8, 9, … Read more

advertisement

Java Program to Find the Row with Maximum Number of 1s

This is the Java Program to Find the Row with the Maximum Number of 1’s in a Sorted Matrix. Problem Description Given a boolean matrix of 0’s and 1’s, where each row is sorted, print the row first with the maximum number of 1’s. Example: Matrix: 0 0 1 1 0 0 1 1 0 … Read more

advertisement

Java Program to Find the Largest and Smallest Word in a String

This is the Java Program to Find the Largest and Smallest Word Problem Description Given a string of characters, find the largest and the smallest word if two or more words are the largest or smallest then display the one that occurs first in the string. Example: String x = “We belong to Russia” Output … Read more

advertisement

Java Program to Find a Pair of Elements with the Given Difference

This is the Java Program to Print Pairs of Elements that have the Given Difference. Problem Description Given an array of n integers and a value, say m. Find out the pairs of elements from the array, whose difference is value m. Example: Array = [ 1, 2, 4, 5, 8, 10, 11] m = … Read more

advertisement

Java Program to Find Two Elements whose Sum is Equal to a Given Number

This is the Java Program to Find Two Elements whose Sum is Equal to a Given Number. Problem Description Given an array of n integers and a value, say m. Find out the pairs of elements from the array, whose sum values m. Example: Array = [ 1, 2, 4, 5, 8, 10, 11] m … Read more

advertisement

Java Program to Merge Two Arrays

This is the Java Program to Merge Two Arrays in Order. Problem Description Given two arrays of integers, merge them into a single sorted array in order. Example: Array1: [1,2,3,4,5] Array2: [2,3,6,7,8] Output: Array = [1,2,2,3,3,4,5,6,7,8] Problem Solution Create a new array of size equal to the sum of the sizes of the two arrays. … Read more

advertisement

Java Program to Print All the Leaders in an Array

This is the Java program to print all the leaders in an array. Problem Description Given an array of integers, find and print all the leaders of the array. A leader is defined as an element of the array which is greater than all the elements following it. The rightmost element is always a leader. … Read more

advertisement

Java Program to Split the Array and Add First Part to the End

This is the Java Program to Split an Array and Concatenate First Part to the End. Problem Description Given an array of integers, and a value n, denoting the number of parts in which array is to be splitted. Concatenate the first part of the array to the end. Example: Array1: [1,2,3,4,5] n = 3 … Read more

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.