Finding the largest mirror image of a set of integers present in an array of integers [on hold]











up vote
0
down vote

favorite












In an array, a "mirror" section is a group of contiguous elements with a group that appears elsewhere in the array with the same elements in reverse order. Write a method that takes in an int array and returns the size of the largest mirror section found in the given array.



public static void main(String args) {
int array = {3,4,5,7,8,5,4,3};
System.out.println(FreeResponse(array));
}
public static int FreeResponse (int array) {
int count = 0;

if (array.length <=1)
return 0;

for (int x =0; x < array.length ; x++) {
for (int y =0; y <array.length; y--) {
if (array[x] == array[y] && array [x+1]== array[y-1]) {
count++;
}
}
}
return count;
}









share|improve this question







New contributor




MarkS is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by vnp, 200_success, Ludisposed, Sᴀᴍ Onᴇᴌᴀ, Vogel612 9 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – vnp, 200_success, Ludisposed, Sᴀᴍ Onᴇᴌᴀ, Vogel612

If this question can be reworded to fit the rules in the help center, please edit the question.













  • Pretty sure 3 4 5 6 7 8 8 7 7 5 4 3 would not be 3. You need to have a current max, update the max (if appropriate), then reset the count each time the mirror ends.
    – Kristian H
    yesterday








  • 1




    I tried running this on the online java compiler on tutorialspoint.com and it shows an exception: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1 on this line: if (array[x] == array[y] && array [x+1]== array[y-1]) {
    – Sᴀᴍ Onᴇᴌᴀ
    11 hours ago










  • Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
    – Vogel612
    9 hours ago















up vote
0
down vote

favorite












In an array, a "mirror" section is a group of contiguous elements with a group that appears elsewhere in the array with the same elements in reverse order. Write a method that takes in an int array and returns the size of the largest mirror section found in the given array.



public static void main(String args) {
int array = {3,4,5,7,8,5,4,3};
System.out.println(FreeResponse(array));
}
public static int FreeResponse (int array) {
int count = 0;

if (array.length <=1)
return 0;

for (int x =0; x < array.length ; x++) {
for (int y =0; y <array.length; y--) {
if (array[x] == array[y] && array [x+1]== array[y-1]) {
count++;
}
}
}
return count;
}









share|improve this question







New contributor




MarkS is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by vnp, 200_success, Ludisposed, Sᴀᴍ Onᴇᴌᴀ, Vogel612 9 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – vnp, 200_success, Ludisposed, Sᴀᴍ Onᴇᴌᴀ, Vogel612

If this question can be reworded to fit the rules in the help center, please edit the question.













  • Pretty sure 3 4 5 6 7 8 8 7 7 5 4 3 would not be 3. You need to have a current max, update the max (if appropriate), then reset the count each time the mirror ends.
    – Kristian H
    yesterday








  • 1




    I tried running this on the online java compiler on tutorialspoint.com and it shows an exception: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1 on this line: if (array[x] == array[y] && array [x+1]== array[y-1]) {
    – Sᴀᴍ Onᴇᴌᴀ
    11 hours ago










  • Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
    – Vogel612
    9 hours ago













up vote
0
down vote

favorite









up vote
0
down vote

favorite











In an array, a "mirror" section is a group of contiguous elements with a group that appears elsewhere in the array with the same elements in reverse order. Write a method that takes in an int array and returns the size of the largest mirror section found in the given array.



public static void main(String args) {
int array = {3,4,5,7,8,5,4,3};
System.out.println(FreeResponse(array));
}
public static int FreeResponse (int array) {
int count = 0;

if (array.length <=1)
return 0;

for (int x =0; x < array.length ; x++) {
for (int y =0; y <array.length; y--) {
if (array[x] == array[y] && array [x+1]== array[y-1]) {
count++;
}
}
}
return count;
}









share|improve this question







New contributor




MarkS is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











In an array, a "mirror" section is a group of contiguous elements with a group that appears elsewhere in the array with the same elements in reverse order. Write a method that takes in an int array and returns the size of the largest mirror section found in the given array.



public static void main(String args) {
int array = {3,4,5,7,8,5,4,3};
System.out.println(FreeResponse(array));
}
public static int FreeResponse (int array) {
int count = 0;

if (array.length <=1)
return 0;

for (int x =0; x < array.length ; x++) {
for (int y =0; y <array.length; y--) {
if (array[x] == array[y] && array [x+1]== array[y-1]) {
count++;
}
}
}
return count;
}






java array






share|improve this question







New contributor




MarkS is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




MarkS is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




MarkS is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









MarkS

1




1




New contributor




MarkS is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





MarkS is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






MarkS is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold as off-topic by vnp, 200_success, Ludisposed, Sᴀᴍ Onᴇᴌᴀ, Vogel612 9 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – vnp, 200_success, Ludisposed, Sᴀᴍ Onᴇᴌᴀ, Vogel612

If this question can be reworded to fit the rules in the help center, please edit the question.




put on hold as off-topic by vnp, 200_success, Ludisposed, Sᴀᴍ Onᴇᴌᴀ, Vogel612 9 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – vnp, 200_success, Ludisposed, Sᴀᴍ Onᴇᴌᴀ, Vogel612

If this question can be reworded to fit the rules in the help center, please edit the question.












  • Pretty sure 3 4 5 6 7 8 8 7 7 5 4 3 would not be 3. You need to have a current max, update the max (if appropriate), then reset the count each time the mirror ends.
    – Kristian H
    yesterday








  • 1




    I tried running this on the online java compiler on tutorialspoint.com and it shows an exception: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1 on this line: if (array[x] == array[y] && array [x+1]== array[y-1]) {
    – Sᴀᴍ Onᴇᴌᴀ
    11 hours ago










  • Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
    – Vogel612
    9 hours ago


















  • Pretty sure 3 4 5 6 7 8 8 7 7 5 4 3 would not be 3. You need to have a current max, update the max (if appropriate), then reset the count each time the mirror ends.
    – Kristian H
    yesterday








  • 1




    I tried running this on the online java compiler on tutorialspoint.com and it shows an exception: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1 on this line: if (array[x] == array[y] && array [x+1]== array[y-1]) {
    – Sᴀᴍ Onᴇᴌᴀ
    11 hours ago










  • Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
    – Vogel612
    9 hours ago
















Pretty sure 3 4 5 6 7 8 8 7 7 5 4 3 would not be 3. You need to have a current max, update the max (if appropriate), then reset the count each time the mirror ends.
– Kristian H
yesterday






Pretty sure 3 4 5 6 7 8 8 7 7 5 4 3 would not be 3. You need to have a current max, update the max (if appropriate), then reset the count each time the mirror ends.
– Kristian H
yesterday






1




1




I tried running this on the online java compiler on tutorialspoint.com and it shows an exception: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1 on this line: if (array[x] == array[y] && array [x+1]== array[y-1]) {
– Sᴀᴍ Onᴇᴌᴀ
11 hours ago




I tried running this on the online java compiler on tutorialspoint.com and it shows an exception: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1 on this line: if (array[x] == array[y] && array [x+1]== array[y-1]) {
– Sᴀᴍ Onᴇᴌᴀ
11 hours ago












Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
– Vogel612
9 hours ago




Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
– Vogel612
9 hours ago















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Список кардиналов, возведённых папой римским Каликстом III

Deduzione

Mysql.sock missing - “Can't connect to local MySQL server through socket”