Skip to content

Instantly share code, notes, and snippets.

@elswit
Created December 16, 2013 06:53
Show Gist options
  • Save elswit/7983256 to your computer and use it in GitHub Desktop.
Save elswit/7983256 to your computer and use it in GitHub Desktop.
Interaction between ArrayList, Char Array and String
ArrayList<Character> array =new ArrayList();
ArrayList currentWindow=new ArrayList();
for (int i=0;i<str.length();i++){
if (str.charAt(i)!='\n')
array.add(str.charAt(i));
}
int maxProduct=1;
int whereIsMax=0;
for (int i=0;i<5;i++)
maxProduct*= Character.getNumericValue(array.get(i));
for (int i=2; i+3<array.size();i++)
{
currentWindow=(new ArrayList<Character> (array.subList(i-2,i+3)));
if (findMovingAverage(currentWindow)>maxProduct){
whereIsMax=i;
maxProduct=findMovingAverage(currentWindow);
}
}
System.out.println(maxProduct);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment