Recursive Digit Sum

  • + 1 comment

    @Utsav1998 Using Java 8 Stream may NOT be faster than a "for loop" but the Stream is more "fluent" in terms of Functional Programming, and the complexity of that stream is indeed O(x).

    • + 1 comment

      then why the hell we are getting time error when using for loop but not when using streams :(

      • + 0 comments

        @Singhalr31 For a simple "for" loop (without Collections or Maps), Java 8 Stream "could be" overkill. If you need to iterate over a "LARGE" Collection (or Map) , however, Java 8 may be faster because you could avoid creating LOTS of "intermediate" Objects by simply streaming data in the Collection from one operation to another.