Java Program to Reverse Each Word in a String

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 Find the Number Occurring 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

Java Program to Cyclically Permute the Elements of an Array

This is the Java Program to Cyclically Permute the Elements of an Array. Problem Description Given an array of integers, cyclically permute its elements, that is, shift each array element to the left by one index. The first value will go into the last index. Example: Array: [1,2,3,4,5] Output: [2,3,4,5,1] Problem Solution Store the first … Read more

advertisement

Java Program to Find the Frequency of All Duplicate Elements in an Array

This is the Java Program to Find Repeated Elements and the Frequency of Repetition. Problem Description Given an array of integers, find and print the repeated elements and their frequency of repetition. Example: Array: [1,2,3,4,5,5,3] Output: Element—–>Frequency 3—–>2 5—–>2 Problem Solution Sort the array, and find the frequency of each repeated element and print it. … Read more

advertisement

Java Program to Find the Address of an Array

This is the Java Program to Find Address of an Array Element Given the Base Address. Problem Description Given the base address of an array, and the element size. Find out the address of the given element. Example: Base address = 2400 Element Size = 5 Element index = 6 Output: Element address = 2430 … Read more

advertisement

Java Program to Check if Any Anagram of a String is Palindrome or Not

This is the Java Program to Check if Any Anagram of the String is a Palindrome Problem Description Given a string, check whether any of its anagrams is palindrome or not. An anagram is just a new word formed by permuting the letters of the string. Example: String x = “ACBDABD” Output = Yes Problem … Read more

advertisement

Java Program to Find the Number Occurring Even Number of Times

This is the Java Program to Print Elements Which Occurs Even Number of Times. Problem Description Given an array of elements, print the elements whose frequency is even. Example: array = {5, 5, 2, 2, 2, 4, 4, 1, 7, 1} Output = 5 4 1 Problem Solution Create a separate array of boolean values … Read more

advertisement

Java Program to Find Pythagorean Triplets in an Array

This is the Java Program to Check if There are Any Pythagorean Triplets in the Array. Problem Description Given an array of integers, check for any triplet of elements say a, b, and c where all three elements form a Pythagorean triplet, that is, c2 = a2 + b2 Example: Array = [1, 3, 4, … Read more

advertisement

Java Program to Remove All Adjacent Duplicates from String

This is the Java Program to Delete Adjacent Pairs of Repeated Characters. Problem Description Given a string, find and remove all the adjacent pairs of repeated characters. Example: String x = “ABBCCCD” Output = “ACD” Problem Solution Create a stack and push the first character of the string on it. Now, iterate through the string, … Read more

advertisement

Java Program to Find the Longest SubString Without Any Repeated Characters

This is the Java Program to Find the Longest SubString Without Any Repeated Characters Problem Description Given a string, find and print the longest substring without any repeating characters, that is all the characters in the substring must be unique. Example: String x = “ABBCDFGHC” Output = “BCDFGH” Problem Solution Create a stack and push … 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.