Skip to main content

New answers tagged

3 votes

Wait for results/failure of an unreliable async operation

In general, this is what CompletableFuture exists for so in that sense, the solution is just fine. But there are ways to improve it. The fact that people have ...
TorbenPutkonen's user avatar
1 vote

repllib.java - a tiny Java library for implementing simple REPL (Read, Evaluate, Print, Loop) programs

The architecture of the library is quite restrictive and it could benefit from generics. First of all, this is a REPL library but it does not provide any helpful tools for the Reading, Printing or the ...
TorbenPutkonen's user avatar
4 votes
Accepted

repllib.java - a tiny Java library for implementing simple REPL (Read, Evaluate, Print, Loop) programs

i have gone through part of the code. my comments below ReplParser in addStatement() you inquire if statementList.contains(statement). you have an api method that does exactly that, so you should use ...
Sharon Ben Asher's user avatar
2 votes

Finding Special Parts in a Word

In such code, one should look for rules, smart logic. Here we have sequences x² and xyⁿx. (As already said in an earlier answer, with n = 0 one covers the first sequence.) The logic here is detecting ...
Joop Eggen's user avatar
  • 4,186
4 votes

Finding Special Parts in a Word

...
TorbenPutkonen's user avatar
4 votes
Accepted

Finding Special Parts in a Word

The "length 2" rule is unnecessary, just ignore it and read the "length ≥ 3" rule as "length ≥ 2" instead. You can simplify your code accordingly, removing the ...
Robert's user avatar
  • 201
-3 votes

Finding Special Parts in a Word

To reduce time complexity, we can avoid redundant substring operations and take advantage of string patterns. This strategy aims to solve the problem efficiently, with a time complexity closer to O(n²)...
Somesh Diwan's user avatar
3 votes
Accepted

Efficient way to win points in chocolate bowl game

The loop in skipsNeededToWin can take long. It has two phases: For some time, both you and your friend always take bites. After that, only you take bites, and your ...
Robert's user avatar
  • 201
6 votes
Accepted

Implementing Dependency Injection into a JavaFX CRUD Application

Just a few stylistic comments. I'm not familiar with JavaFX so I can't really comment on how you have structured the application. It is a common practise that package names match some domain name ...
TorbenPutkonen's user avatar

Top 50 recent answers are included