answersLogoWhite

0


Best Answer

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.util.Vector; /**

*

*/ /**

* @author omnipath

*

*/

public class Palindrome { /**

* @param args

*/

public static void main(String[] args) { // open up standard input

BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String string = null; // readLine() method try { string = br.readLine(); } catch (IOException ioe) { System.out.println("IO error trying to read input!"); System.exit(1); }

Palindrome palindromeCase = new Palindrome(string);

System.out.println("The longest palindrome is: " + palindromeCase.palindrome);

System.out.println("The length of the longest palindrome is: " + palindromeCase.palindrome.length());

System.out.println("Counter is: " + palindromeCase.PalindromeCounter);

} String originalString;

String palindrome;

Vector vectPalindromes;

int palindromeLength;

int PalindromeCounter; public Palindrome(String s) {

PalindromeCounter = 0;

this.palindrome = "";

this.palindromeLength = this.palindrome.length();

this.originalString = s;

this.calculateLongestPalindrome(s);

} public void calculateLongestPalindrome(String s) {

if (s.length() == 1) {

this.palindrome = this.originalString;

this.palindromeLength = this.palindrome.length();

} this.parseForPalindrome(this.originalString); } public void parseForPalindrome(String s) {

PalindromeCounter++;

if (s.length() -1; i--) {

sb.append(s.charAt(i));

}

return sb.toString();

}

}

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Largest palindrome substring of a string?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

The substring method returns?

"[Substr] returns a string object with its contents initialized to a substring of the current object."


What is substr function does in c?

it will give the substring of length(as per the user) from the actual string,and the starting length from where it has to copy the substring from actual should be given by the user.


How do you use sub string in java?

Substring method creates smaller string form bigger string , every time a new string is created but original character array buffer is used. so even if original string is 1G in size and substring is just 1K memory held by substring is 1G because of backed array. this can cause memory leak and prevent original string from garbage collection even if there is no direct reference.


Program to check that given string is palindrome or not in C?

/*To check whether a string is palindrome*/includeincludevoid main () { int i,j,f=0; char a[10]; clrscr (); gets(a); for (i=0;a[i]!='\0';i++) { } i--; for (j=0;a[j]!='\0';j++,i--) { if (a[i]!=a[j]) f=1; } if (f==0) printf("string is palindrome"); else printf("string is not palindrome"); getch (); }


Bluej program-read a string and check if the given string is a palindrome?

import java.util.Scanner; public class Palindrome{ public static void main(String[] args){ String front; String back =""; char[] failure; String backwards; Scanner input=new Scanner(System.in); System.out.print("Enter a word: "); front=input.next(); front=front.replaceAll(" ", ""); failure=front.toCharArray(); for (int i=0; i<failure.length; i++){ back=failure[i] + back; } if (front.equals(back)){ System.out.print("That word is a palindrome"); }else System.out.print("That word is not a palindrome"); }}

Related questions

What is the largest palindrome number?

It is a string of nines that goes on forever.


The substring method returns?

"[Substr] returns a string object with its contents initialized to a substring of the current object."


What is th function of the charindex?

The CHARINDEX function in SQL is used to find the position of a specific character or substring within a string. It returns the starting position of the substring or character within the given string.


How do you determine if a given string is palindrome or not?

Reverse the string and compare it to the original. If they match, then it is a palindrome.


What is substr function does in c?

it will give the substring of length(as per the user) from the actual string,and the starting length from where it has to copy the substring from actual should be given by the user.


How do you use sub string in java?

Substring method creates smaller string form bigger string , every time a new string is created but original character array buffer is used. so even if original string is 1G in size and substring is just 1K memory held by substring is 1G because of backed array. this can cause memory leak and prevent original string from garbage collection even if there is no direct reference.


Do I need to write a program to find a substring in a given string in c plus plus?

No.


What are examples of a palindrome program forward and backwards?

To check if a string is a palindrome, point to each end of the string and work inwards towards the middle. If the characters pointed at differ, the string is not a palindrome. When the pointers meet or cross each other, the string is a palindrome. Note that the string cannot contain whitespace or punctuation and comparisons must not be case-sensitive.


What is a string palindrome?

A string palindrome is some words that put together form a sentence. An example is "A man, a plan, a canal - Panama".


What is string palindrome?

A string palindrome is some words that put together form a sentence. An example is "A man, a plan, a canal - Panama".


Python Substring: What is a Substring in Python?

One of the most used types in the Python language is the string. Characters can be figuratively enclosed in quotation marks to create strings. Python treats single quotes the same way it treats double-quotes. In Python, creating strings is as simple as assigning a value to a variable. For Example: Variable1 = "Hello world" Variable2 = "Welcome to the world of Python." What is a Substring? Just picture what a car manufacturer does to quickly and effectively determine the last five digits of a chassis number. The idea of Substring conceals the answer to this puzzle. According to proper language analysis and computer science, a substring is a sequence of characters included within a string. In other words, a substring can be defined as a portion of a string that is created using one of the methods listed by the Python string, which also determines the substring index and other details. A component or subset of a string is another method to define a substring. The substring process includes any changes made to text data that make up a string. For example: "This work is excellent. We must pursue it. It is a particular kind of string, and "We must pursue it" is a particular kind of Substring. Slicing is a Python function that can be used to extract a substring. Programmers frequently desire to divide the data into separate pieces for a particular reason. For instance, if a developer needs to use only the user's first name and has data that includes the user's whole name, the developer will need to divide the data into two pieces, such as the user's forename and surname. The challenge that arises now is how a Python programmer will carry out this task. The correct response is that a developer must engage in "string slicing" to complete this task. String slicing is a Python technique for extracting a specific portion of a string, which is then utilized as a "substring." How is a Substring created from a String that is provided? Python supports several methods for creating a substring from a string. But the slicing process is one of the most used methods in Python for creating a substring from a string. Slicing in Python Based on their position in a string, a software developer can access the characters within it at any time. Characters are assembled into strings. The term for this is indexing. The indexing method in Python returns a one-character string from the supplied offset or location. Now, slicing is the technique used to do this action when a portion of a string, rather than simply a single character, is required. What is String Slicing In Python? Slices, which return a complete necessary chunk in a single step rather than a single item, might be considered a generalized indexing type. Slicing allows for the execution of various tasks, including the extraction of data columns, the removal of leading and trailing characters, and many more. Slicing relies on a very basic idea. A new string object containing the section indicated by the offset pair is returned by Python when a string is indexed using a pair of offsets separated by a colon (:). The right offset's upper bound is non-inclusive in the offset pair, whereas the left offset's lower bound is included. Therefore, the left and right boundaries will default to values of 0 and the length of the string you are slicing, respectively, if neither of the offsets is given. Let's get into the specifics to comprehend the Slicing operator's syntax. Syntax of Slicing Operator As we have previously read earlier, the slicing operator is thought to be one of the best ways to create a substring. Let's examine the slicing operator's syntax: String(steps, startIndex, endIndex) where, • startIndex: This is the Substring's initial index. The character is a part of the Substring at this index. StartIndex is presumed to be equal to 0 if it is not set. • endIndex: This is Substring's final index. The character is absent from the Substring at this index. If the endIndex value is left blank, it is automatically considered equal to the length of the entire string. • Step: After the first character is extracted from the string, it is known how many characters to proceed with. The default setting is 1. Interested in becoming a data scientist? To learn more about Substring and other Python methods, enroll in a data science course in Mumbai, please visit Learnbay.co


Program to check that given string is palindrome or not in C?

/*To check whether a string is palindrome*/includeincludevoid main () { int i,j,f=0; char a[10]; clrscr (); gets(a); for (i=0;a[i]!='\0';i++) { } i--; for (j=0;a[j]!='\0';j++,i--) { if (a[i]!=a[j]) f=1; } if (f==0) printf("string is palindrome"); else printf("string is not palindrome"); getch (); }