🚨 Potential Bug Identified in LeetCode Execution Time Calculation 🚨 I recently noticed an issue with how LeetCode calculates and displays code execution time. By adding a simple static block with a shutdown hook, it is possible to alter the displayed runtime of a submitted solution. This indicates that the execution time can be influenced outside the actual algorithm logic, which should ideally not be possible. Below is the code snippet that demonstrates this behavior: static { Runtime.getRuntime().addShutdownHook(new Thread(() -> { try (FileWriter writer = new FileWriter("display_runtime.txt")) { writer.write("0"); } catch (IOException e) { e.printStackTrace(); } })); } This suggests a bug on LeetCode’s end, where execution time tracking may be relying on artifacts that can be manipulated during JVM shutdown. Sharing this for awareness and hoping the LeetCode team can look into it to ensure fair and accurate performance measurement for all submissions. #LeetCode #BugReport #Java #CompetitiveProgramming #SoftwareEngineering #JVM
LeetCode Execution Time Bug Identified
More Relevant Posts
-
𝑷𝒐𝒕𝒆𝒏𝒕𝒊𝒂𝒍 𝑩𝒖𝒈 𝑰𝒅𝒆𝒏𝒕𝒊𝒇𝒊𝒆𝒅 𝒊𝒏 𝑳𝒆𝒆𝒕𝑪𝒐𝒅𝒆 𝑬𝒙𝒆𝒄𝒖𝒕𝒊𝒐𝒏 𝑻𝒊𝒎𝒆 𝑪𝒂𝒍𝒄𝒖𝒍𝒂𝒕𝒊𝒐𝒏 I recently noticed an issue with how LeetCode calculates and displays code execution time. By adding a simple static block with a shutdown hook, it is possible to alter the displayed runtime of a submitted solution. This indicates that the execution time can be influenced outside the actual algorithm logic, which should ideally not be possible. Below is the code snippet that demonstrates this behavior: static { Runtime.getRuntime().addShutdownHook(new Thread(() -> { try (FileWriter writer = new FileWriter("display_runtime.txt")) { writer.write("0"); } catch (IOException e) { e.printStackTrace(); } })); } This suggests a bug on LeetCode’s end, where execution time tracking may be relying on artifacts that can be manipulated during JVM shutdown. Sharing this for awareness and hoping the LeetCode team can look into it to ensure fair and accurate performance measurement for all submissions. #LeetCode #Java #JVM #CompetitiveProgramming #SoftwareEngineering #Performance #Debugging LeetCode
To view or add a comment, sign in
-
🚨 Potential Bug Identified in LeetCode Execution Time Calculation 🚨 I recently noticed an issue with how LeetCode calculates and displays code execution time. By adding a simple static block with a shutdown hook, it is possible to alter the displayed runtime of a submitted solution. This indicates that the execution time can be influenced outside the actual algorithm logic, which should ideally not be possible. Below is the code snippet that demonstrates this behavior: static { Runtime.getRuntime().addShutdownHook(new Thread(() -> { try (FileWriter writer = new FileWriter("display_runtime.txt")) { writer.write("0"); } catch (IOException e) { e.printStackTrace(); } })); } This suggests a bug on LeetCode’s end, where execution time tracking may be relying on artifacts that can be manipulated during JVM shutdown. Sharing this for awareness and hoping the LeetCode team can look into it to ensure fair and accurate performance measurement for all submissions. hashtag #LeetCode #Java #TimeComplexity #Algorithms #CompetitiveProgramming #SoftwareEngineering #Programming #BugReport #DeveloperCommunity #TechLearning
To view or add a comment, sign in
-
-
LeetCode Problem Solved | #1209. Remove All Adjacent Duplicates in String II Today I worked on LeetCode 1209, which is a great extension of the classic adjacent-duplicate problem and a perfect example of the stack pattern in DSA. 🧠 Problem Summary Given a string s and an integer k, repeatedly remove k adjacent identical characters until no more removals are possible. Example: Input: s = "deeedbbcccbdaa", k = 3 Output: "aa" 💡 Approach (Using Stack) 1. Traverse the string character by character 2. If the current character matches the stack top -> increment count 3. If count reaches k -> pop from stack 4. Otherwise -> push a new Pair 5 .Finally, rebuild the string from the stack #LeetCode #DSA #Java #Stack #ProblemSolving #CodingPractice
To view or add a comment, sign in
-
-
Day 38: Efficiency through String Balancing! ⚖️ Problem 1653: Minimum Deletions to Make String Balanced Today’s challenge was to find the minimum deletions needed to ensure no 'b' comes before an 'a' in a string. It’s a classic problem that tests your ability to think about state transitions across a sequence. I implemented a prefix/suffix counting strategy. Instead of brute-forcing every deletion possibility, I pre-calculated the total count of 'a's and then iterated through the string while keeping a running count of 'b's. At each position, the sum of 'b's seen so far (to be deleted if they stay) and 'a's remaining (to be deleted if they appear later) gave me the cost to balance at that specific "split point." By tracking the minimum sum across all possible split points, I achieved a clean O(n) solution with just two passes. It’s a great reminder that sometimes "balancing" a problem is just about counting what’s on either side of the fence! #LeetCode #Java #StringAlgorithms #Optimization #CodingChallenge #ProblemSolving #Algorithms
To view or add a comment, sign in
-
-
The moment Java systems begin handling snapshots, events, concurrent state, or domain aggregates, object copying stops being trivial. This is where the Copy Constructor approach becomes essential. A copy constructor gives developers: 🔹 full control over what gets duplicated 🔹 guaranteed avoidance of Cloneable's broken contract 🔹 clear semantics for nested objects 🔹 deterministic behavior under concurrency 🔹 predictable memory and lifecycle boundaries clone() suffers from reflection, shallow copying traps, CloneNotSupportedException, and inheritance fragility. Copy constructors avoid all of this by tying copying logic directly to the domain — not to a runtime mechanism. The result is a design where every replicated object is intentional, safe, and structurally consistent. This is exactly what high-integrity systems — financial flows, rule engines, schedulers, auditing pipelines — depend on. When correctness matters, explicit copying wins. Hashtags: #Java #CopyConstructor #AdvancedJava #JavaInternals #BackendEngineering #CleanArchitecture #ObjectOrientedDesign #CodeQuality #SoftwareEngineering #ConcurrencyControl #Immutability #ProgrammingBestPractices #DeepWork #JavaCommunity #HighPerformanceJava #TechLearning
To view or add a comment, sign in
-
Day 8/100 – LeetCode Challenge 🚀 Problem: Implement strStr() Approach: Checked every possible starting index in haystack Matched characters one by one with needle Time Complexity: O(n × m) Space Complexity: O(1) Key takeaway: Brute-force solutions are fine when constraints allow them. Understanding the basic approach comes before optimization. #LeetCode #100DaysOfCode #DSA #Java #ProblemSolving #100DaysOfLeetCode
To view or add a comment, sign in
-
-
Day 7/100 – LeetCode Challenge 🚀 Problem: Remove Element Approach: Used two pointers Shifted non-matching elements to the front Returned the count of valid elements Time Complexity: O(n) Space Complexity: O(1) (in-place) Key takeaway: In-place array problems often reduce to index management, not extra data structures. #LeetCode #100DaysOfCode #DSA #Java #ProblemSolving #InterviewPrep #100DaysOfLeetCode
To view or add a comment, sign in
-
-
SOLID Principles – Explained Simply S – Single Responsibility One class = one responsibility = one reason to change. O – Open/Closed Extend behavior, don’t modify existing code. L – Liskov Substitution A subclass should seamlessly replace its parent class. I – Interface Segregation Many small, specific interfaces are better than one large interface. D – Dependency Inversion Depend on abstractions, not concrete implementations. #SOLID #CleanCode #Java #SpringBoot #SoftwareEngineering #BackendDevelopment #BestPractices
To view or add a comment, sign in
-
Finished the code-based part of the Loops module by comparing different loop structures. The logic stayed the same, but the control flow changed. // for loop for (int i = 1; i <= 5; i++) { System.out.print(i + " "); } // while loop int i = 1; while (i <= 5) { System.out.print(i + " "); i++; } // do-while loop int j = 1; do { System.out.print(j + " "); j++; } while (j <= 5); What this comparison made clear: - for is best when the number of iterations is known - while fits when the loop depends on a condition - do-while guarantees at least one execution - choosing the right loop improves readability, not just correctness This felt like a good way to close the practical part of loops. #Java #Loops #LearningInPublic #Beginner #DSA
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development