import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class Problem_18 {
private static int heightOfTree = 100;
private final String fileName = "problem_67.in";
private int[][] tree;
public int maxValue() throws IOException {
readTree();
for (int i = Problem_18.heightOfTree - 2; i >= 0; i--)
for (int j = 0; j <= i; j++)
tree[i][j] += tree[i + 1][j] > tree[i + 1][j + 1] ? tree[i + 1][j] : tree[i + 1][j + 1];
return tree[0][0];
}
private void readTree() throws IOException {
tree = new int[Problem_18.heightOfTree][];
BufferedReader bufferedReader = new BufferedReader(new FileReader(fileName));
for (int i = 0; i < Problem_18.heightOfTree; i++) {
tree[i] = new int[i + 1];
String[] values = bufferedReader.readLine().split(" ");
for (int j = 0; j <= i; j++)
tree[i][j] = Integer.parseInt(values[j]);
}
}
public static void main(String[] args) throws IOException {
System.out.println(new Problem_18().maxValue());
}
}
In case you are building a Web Application which needs a simple feature like selecting address from Google Map location suggestion then below solution can be used. It is a very simple solution where input fields of the HTML are binded with Google Maps Web service.
<!DOCTYPE html> <html> <head> <title>Place Autocomplete Address Form</title> <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&libraries=places"></script> <script> function initialize() { var first_input = document.getElementById('firstTextField'); var second_input = document.getElementById('secondTextField'); var first_autocomplete = new google.maps.places.Autocomplete(first_input); var second_autocomplete = new google.maps.places.Autocomplete(second_input); } google.maps.event.addDomListener(window, 'load', initialize); </script> <body> <h2>Test of Populating Text Boxes</h2><br/><br/> <i>Starting Point : </i><input id="firstTextField" type="text" size="50">   <i>Destination Point : </i> <input id="secondTextField" type="text" size="50"> </body> </html>
