Skip to main content

New answers tagged

1 vote

calculate the number of ways to pick two different indices

Your algorithm is a loop of loop, giving a quadratic complexity on the number of elements. You want to count (i, j) where (a[i] + a[j]) % k == 0 The trick is to ...
Joop Eggen's user avatar
  • 4,786
4 votes

On the absence of protected member concept in javascript

I've gone down this, for lack of a better description, rabbit hole - for example using WeakMap to encapsulate the class definition hierarchy itself, utilizing accessors which verify membership, and ...
Nolo's user avatar
  • 171
3 votes

Web component (custom element) for a Swing-like (Java) tree with a shared style sheet

I'd say the following changes would help with the overall conciseness and should not affect performance: Remove connectedMoveCallback; This isn’t a valid lifecycle ...
Chip01's user avatar
  • 808

Top 50 recent answers are included