Created
December 16, 2013 06:53
-
-
Save elswit/7983256 to your computer and use it in GitHub Desktop.
Interaction between ArrayList, Char Array and String
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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