Share Your Experience: Take the 2024 Developer Survey

# Tag Info

### Printing longest sequence of zeroes

Optional abuse In the code you shared, Optional is used only to create a chain of method calls and avoid writing conditional ...
• 1,039
Accepted

### Leetcode: Number of Islands - BFS (Queue vs Recursion)

Performance Figures First of all, regarding these figures in milliseconds. They can be useful, to indicate whether something is wrong with the algorithm, but they can hardly be considered accurate. ...
• 1,039
Accepted

### Optimizing a Function to Check Pronic Numbers in JavaScript

Add guard The function requires a unsigned integer as an argument. A JS number is a floating point double (64bit floating point value). Guard function against bad input by checking is argument ...
• 22.1k

### Optimizing a Function to Check Pronic Numbers in JavaScript

quadratic complexity how to improve this function's performance The time complexity of these loops is out of control! ...
• 27.6k
Accepted

### Optimizing a Function to Generate a Row of Consecutive Odd Numbers in a Triangle

Quadratic, Linear, or Constant This is a linear problem $O(n)$ (possibly constant $O(1)$ See bottom of answer) however your solution is quadratic $O(n^2)$. Note: that the function expects that ...
• 22.1k

### Optimizing a Function to Generate a Row of Consecutive Odd Numbers in a Triangle

memory consumption it fails to run for large indices I'm guessing due to malloc() fail. The OP computes (roughly) a 2-dimensional matrix: ...
• 27.6k

### Leetcode - First Unique Character in a String

Pay attention to Constraints While cracking algorithmic problems, pay very close attention to the constraints of the problem at hand. They can often give valuable clues on how to attack the problem. ...
• 1,039

### Leetcode 55. Jump Game solution

TC = O(N) SC = O(1) Iterates through the array, updating the maximum reachable index and decrementing the steps available. If it exhausts steps before reaching the end, it returns false; otherwise, it ...

### Leetcode - First Unique Character in a String

In Java Use the FirstIndexOf() and LastIndexOf() if these both return the same number then its the unique character in the statring of the string return the index of it break the loop. This is the ...

### Coding challenge for mixing a string

Re: your question about a better way of de-deduplicating, a nice way of de-duplicating frequency entries while also removing the need to do entry cleanup via ...
• 1,608

### Advent of code 2023 day 5 in Java: mapping integer ranges to new integer ranges

Use proper types / Avoid abusing Arrays and Collections Put on yourself in the shoes of the code reader and try to answer the question: "What do they make of this type?" ...
• 1,039
Accepted

### Advent of code 2023 day 5 in Java: mapping integer ranges to new integer ranges

Your code needs a complete rewrite. I'll show you some pointers towards the next iteration. import java.io.File; // read file Forget these comments. The reason why ...
• 7,445