joaoarthurbm
BAN USERThis is a very open question. I would start by asking details on the application. However, to start the discussion, I can point some aspects to test:
- Check whether the user has permission to install
- Check whether the disk has enough space
- Check internet connection. Maybe use trace route to provide more details in case the connection has a problem.
Three solutions came to my mind.
1) Split the string and iterate over the array starting from the last position to the first one.
2) Iterate over the string from the last position and adding the chars into a Stack. Every time the iteration reaches a ' ', remove the elements from the stack and print.
3) Using no high level language methods or extra data structures. Similar to the first answer to this question. Using two indexes and iterating from the last position. Here is the code:
String s = "this is a test";
int current, prev;
current = prev = s.length()-1;
while (current >= 0) {
if (s.charAt(current) != ' ') {
current--;
} else {
for (int i = current+1; i <= prev; i++)
System.out.print(s.charAt(i));
System.out.print(" ");
prev = current-1;
current--;
}
}
for (int i = 0; i <= prev; i++) {
System.out.print(s.charAt(i));
}
You don't need a HashMap. A Set would work and require less space.
- joaoarthurbm November 26, 2013