Ad
  • Default User Avatar

    You're right... these things are not taught at schools too much. The emergence of computing brought to light some aspects of math that were less stressed before: Graph theory, Number Theory, Combinatorics, Discrete Math etc. Usually these topics are not well adressed in schools - the highschool curriculum (in many countries) is focused on algebra, calculus and geometry, and more suitable for learning physics or economics or engineering than computers.
    And how needed are those hacks? when playing competitive programming or here on this site or maybe at some job interview - these tricks are awesome going from O(n) or O(n2) to easy one liner O(1)... I doubt how needed they are in real life programming. Probably not much, and if you ever need them, google them out

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Yeah, but you need a proof by induction to do that. Did you do one yourself or (like "plebs") take it from the internet?

  • Default User Avatar

    Pretty much what I did, but I included a pop for odd lengths of arr. Thought that the odd case where a = 1 and b is null may be a problem, clearly I am dum dum.

  • Default User Avatar

    How could you not do it this way. Plebs went and summed them all up

  • Default User Avatar

    good job, i like how elegant your solution is.

  • Default User Avatar