Java Pitfalls

Правка en5, от ajxu2, 2023-05-20 03:18:37

Recently, I participated in Codeforces Round 873 (Div. 2). I was doing well, and in the last 5 minutes of the contest I solved problem D1, putting me at rank 200 and with CM performance. I was happy with myself until this happened:

I saw that I got TLE on test case 13 and quickly realized what happened. I chose to use Java in this round, and I had somehow fallen in another one of Java's traps. Now, I've decided to compile a comprehensive list of these pitfalls so no one can FST to them again. (Hopefully after you see this you'll be convinced to just use C++.)

1. Array sorting

Problem
Solution 1
Solution 2
Solution 3

2. String concatenation

Problem
Solution

3. Input/output

Problem
Solution

4. Comparing objects

Problem
Solution

5. Stacks

Problem
Solution

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en9 Английский ajxu2 2024-06-18 22:26:56 210 Tiny change: 'ing like\n~~~~~\nD' -> 'ing like\n\n~~~~~\nD'
en8 Английский ajxu2 2023-05-20 05:36:24 0 (published)
en7 Английский ajxu2 2023-05-20 05:36:10 202
en6 Английский ajxu2 2023-05-20 03:20:50 27
en5 Английский ajxu2 2023-05-20 03:18:37 3023 Tiny change: 'en you're ' -> 'en you're using data structures like `ArrayList<Integer>`.'
en4 Английский ajxu2 2023-05-19 23:10:13 1784 Tiny change: ' use C++.)' -> ' use C++.)\n\n**1. $O(N^2)$ array sorting**'
en3 Английский ajxu2 2023-05-19 22:45:17 66 Tiny change: 'o/df98N3R)' -> 'o/df98N3R)\n\nsdkjfghasdijfas'
en2 Английский ajxu2 2023-05-19 22:42:21 16 Tiny change: 'appened:\n![ ](https://' -> 'appened:\n\n![sdfusdhfshdaf](https://'
en1 Английский ajxu2 2023-05-19 22:41:56 259 Initial revision (saved to drafts)