Project Euler #8 in Ruby
The easiest way to think of this problem is to use a k-character sized window that slides across the number.


First calculate the product of the first k characters
Check to see if the next digit is 0, if it is, keep going until you hit a non-zero element and restart the process from that digit
If the next digit is not 0, then multiply the existing product by that digit and divide by the first digit of the existing product (the number that is going to be dropped off the window)


Keep track of the best sequence found and its product and you have your answer

The beauty of this approach is you only ever look at/multiply an element exactly once, giving O(n) time (where n is the length of the string). Your approach may multiply the same number k times (where k is the length of the window), resulting in O(kn) time, which is quite a bit slower.