Skip to main content
18 events
when toggle format what by license comment
Jul 2, 2022 at 18:10 answer added janos timeline score: 0
May 31, 2022 at 11:39 answer added Joop Eggen timeline score: 0
May 25, 2022 at 6:35 history edited Toby Speight CC BY-SA 4.0
Add an introductory paragraph with the problem statement
May 24, 2022 at 17:02 history edited greybeard CC BY-SA 4.0
embed 3rd party code as quoted code block
May 5, 2022 at 19:00 answer added Blindman67 timeline score: 4
May 5, 2022 at 5:45 comment added Blindman67 @ajax333221 for any list size over ~4 the additional cycles (per iteration) required for a binary search would still result in less total cycles, In complexity terms a binary search is \$O(log(n))\$ which in this case has \$n\$ as the number of unique groups rather than the number of elements. In terms of performance and complexity, and using a binary search to locate the range of a group., the gain is huge even for tiny lists. Yes well "... worth considering ..."
May 4, 2022 at 17:20 comment added ajax333221 @Blindman67 if the list is big yes it would make sense to first find the match using binary search, then find possible neighbors to the left, right and store them. It's worth considering and putting it on the table.
May 3, 2022 at 18:26 comment added Blindman67 If asked in an interview "Find first and last matches on a sorted list" the expectation is a binary search, a flat search would be considered below par. The clue is the "...sorted list"
May 3, 2022 at 7:08 answer added konijn timeline score: 1
May 3, 2022 at 6:45 answer added Zachary Vance timeline score: 1
May 3, 2022 at 6:32 comment added konijn @ajax333221 builtins are written in C, they are bound to be faster than what we can do with JavaScript loops.
May 3, 2022 at 6:30 comment added Zachary Vance Please rewrite the youtuber code as a code block with text.
May 3, 2022 at 2:02 answer added peterSO timeline score: -1
May 3, 2022 at 0:08 history edited 200_success CC BY-SA 4.0
added 167 characters in body
May 2, 2022 at 20:50 history edited 200_success CC BY-SA 4.0
edited tags; edited title; added 73 characters in body
May 2, 2022 at 20:47 comment added ajax333221 in the context of interview questions, like doing your own algorithm so I don't think indexOf and lastIndexOf are allowed, or even if they are, they will probably not be as performant as you having the controll to keep looping the next elements and take advantage of they being sorted.
May 2, 2022 at 19:23 comment added 200_success What is the goal and context for this question? Are you aware that JavaScript has .indexOf() and .lastIndexOf() built in?
May 2, 2022 at 19:19 history asked ajax333221 CC BY-SA 4.0