Ad
  • Custom User Avatar

    Why not try thinking through it with an example and see if with notetaking, you can find a solution that works for you!

    Example, imagine an infinite list of ascending numbers:
    [1, 2, 3, 4, 5, 6, 7, ...] # find a sum 7

    As you go through the list, would you need to parse to infinity to know what values add up to 7? In this constrained example, the fact that ther numbers are ordered gives you the advantage to know that once we're past values that can sum up to 7, that you don't need to look further.

    Beyond that, you know by the time you hit [3, 4] that there's a matching pair, and you didn't even need to look past the 4th value in that list!

  • Default User Avatar

    The JavaScript code isn't executed by the browser, but by Node JS. It's a runtime to run JavaScript outside a browser (in this case: Codewars's server). So it doesn't matter whether you use Chrome/Firefox/etc.

  • Default User Avatar

    can you recommend any reading material for it?

  • Custom User Avatar
  • Default User Avatar

    Basically you are asigning value to your key inside object count.
    (count[s] || 0) + 1 means that if there is no value(count) of that specific letter, value 0 is being assigned to it and then it is increased by 1.
    If we encounter a letter which count is bigger than 1 (not 0 or undefined) than we reach that value and add 1 to it.

  • Custom User Avatar