Java Program to determine whether one string is a rotation of another8 Jan 2025 | 2 min read In this program, we need to check whether a string is a rotation of another string or not. Consider the above example, suppose we need to check whether string 2 is a rotation of string 1. To find this, we concatenate string 1 with string 1. Then, try to find the string 2 in concatenated string. If string 2 is present in concatenated string then, string 2 is rotation of string 1. String 2 deabc is found on the index 3 in concatenated string. So, deabc is rotation of abcde. ALGORITHM
Program:Output: Second string is a rotation of first string Next TopicJava Programs |
In this program, we need to find out the duplicate words present in the string and display those words. Example: big black bug bit a big black dog on his big black nose To find the duplicate words from the string, we first split the string into...
3 min read
In Java, we can create an ATM program for representing ATM transection. In the ATM program, the user has to select an option from the options displayed on the screen. The options are related to withdraw the money, deposit the money, check the balance, and exit. To...
3 min read
Buzz number is another special number in Java that ends with digit 7 or divisible by 7. Unlike Prime and Armstrong numbers, the Buzz number is not so popular and asked by the interviewers. In simple words, a number is said to be Buzz if it ends...
3 min read
Program to print the largest element in an array In this program, we need to find out the largest element present in the array and display it. This can be accomplished by looping through the array from start to end by comparing max with all the...
2 min read
A number is prime if it is divisible by 1 and itself. In other words, a prime number is a natural number with exactly two distinct natural number divisors 1 and itself. For example, 2, 3, 5, 7, 11, etc. are the prime numbers. Note that...
5 min read
In this program, we need to find out the total number of binary search trees can be constructed with n values. Below diagram shows a possible binary search tree with the key value as 3. So, we can construct a total of five binary search...
3 min read
An array numArr[] that contains negative as well as non-negative elements of the size S. Also, the two other numbers, 'left' and 'right', is provided. Our task is to return the number of the sum of the range, such that the sum is lying between the...
12 min read
In this program, we need to search a given node in a doubly linked list. To solve this problem, we will traverse through the list using a node current. Current points to head and start comparing searched node data with current node data. If they are...
5 min read
Java Program to find the frequency of odd & even numbers in the given matrix In this program, we need to find the frequencies of odd and even numbers present in the matrix. In the above example, all odd numbers are represented by the blue square and...
3 min read
Program to Print the Duplicate Elements of an Array | Find Duplicate Elements in an Array in Java Finding duplicate elements in an array is a commonplace programming hassle that assesses the know-how of statistics systems and algorithms. Understanding the different methods to find duplicates efficiently is...
9 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India