Duplicate enum values can hijack your reverse lookup. Two members are assigned the same numeric constant. A console.log reads the enum by that number. In production this can surface as wrong status codes. Logs may point to an unexpected enum name. Buggy conditionals silently pick the last defined key. Comment A, B, C, or D with the output you think appears and defend your choice. #typescript #programming #codinginterview #backend
Enum Value Duplication in TypeScript: Avoiding Silent Bugs
More Relevant Posts
-
DAY->12 Solved Running Sum of 1d Array on LeetCode today. Implemented the solution using the Prefix Sum technique to compute the cumulative sum of elements efficiently. -> Time Complexity: O(n) -> Space Complexity: O(n) All 54/54 test cases passed with 0 ms runtime. Small problems like this help strengthen fundamentals in arrays and prefix sums, which are widely used in many algorithmic problems. #LeetCode #DSA #CodingJourney #Programming #Cplusplus #ProblemSolving
To view or add a comment, sign in
-
-
Minimum Changes to Make Alternating Binary String Intuition A binary string can be alternating in only two ways: 0101... or 1010.... Check one pattern while iterating through the string. If a character doesn’t match the expected bit, we increase a counter cnt (number of changes needed). But this pattern might not be optimal. The operations needed for the other pattern will be: len(s) - cnt So we simply return: min(cnt, len(s) - cnt) This gives the minimum number of changes required to make the string alternating. #problem_solving #leetcode #programming
To view or add a comment, sign in
-
-
Your console logs could be lying to you. A function prints 'call' and a merged namespace logs 'init' while defining a constant. Both run before the function invocation. In production this can mask init‑time side effects. It may cause ordering bugs that appear only after deployment. Flaky tests can pass locally while failing in CI. Comment A, B, C, or D with your answer and defend why you chose it. #typescript #webdevelopment #programming #codinginterview
To view or add a comment, sign in
-
-
k-th Lexicographical Happy String of Length n🪢 Given n and k, return the k-th lexicographical happy string of length n. Thought process Brute force idea: Generate all possible happy strings of length n, Sort them, Return the string at k-1 index Optimization Instead of generating everything and sorting later, we can control the order while generating. During backtracking: Try characters in order → a, b, c Skip if the current character is the same as the previous one This way strings are already generated in lexicographical order, so we can directly return the k-th string. #leetcode #thoughtProcess #problemSolving #programming #recursion #backtracking
To view or add a comment, sign in
-
-
Multithreading in theory vs reality 🧵⚙️ In theory: Every thread executes independently, efficiently, and peacefully. In reality: Race conditions, deadlocks, and thread competition, context switching, synchronization issues etc. 👉 Writing multithreaded code is easy. 👉 Writing correct multithreaded code is the real challenge. #Multithreading #Programming #SoftwareEngineering #BackendDevelopment #CPP #CppProgramming #ModernCPP #Multithreading #Concurrency #ParallelProgramming #SystemProgramming #SoftwareEngineering #CodingLife
To view or add a comment, sign in
-
-
A small C++ tip that can save a lot of unnecessary work: std::vector::reserve() Whenever I’m loading data or building vectors from known sources (files, protobufs, APIs, etc.), I try to remember this. #cpp #cplusplus #programming #softwareengineering
To view or add a comment, sign in
-
-
Multithreading in theory vs reality 🧵⚙️ In theory: Every thread executes independently, efficiently, and peacefully. In reality: Race conditions, deadlocks, and thread competition, context switching, synchronization issues etc. 👉 Writing multithreaded code is easy. 👉 Writing correct multithreaded code is the real challenge. #Multithreading #Concurrency #Programming #SoftwareEngineering #BackendDevelopment #CPP #CppProgramming #ModernCPP #Multithreading #Concurrency #ParallelProgramming #STL #SystemProgramming #SoftwareEngineering #CodingLife
To view or add a comment, sign in
-
-
I wrote a beginner-friendly article explaining 10 Pattern Problems in C++ with diagrams and code. Pattern problems are a great way to improve logic and understanding of loops. Check it out here: https://lnkd.in/grVA7Ggb #Programming #CPP #Coding
To view or add a comment, sign in
-
-
🚀 The #undef Directive (C++) The `#undef` directive removes a previously defined preprocessor symbol. This can be useful for temporarily disabling a macro or conditional compilation block. It's often used in conjunction with `#ifdef` and `#define` to control the behavior of code based on specific conditions. Undefining a symbol allows for dynamic configuration of the compilation process, enabling or disabling certain features or optimizations based on the project's requirements. #c++ #programming #coding #tech #learning #professional #career #development
To view or add a comment, sign in
-
-
Your static initializer logic could silently break your class. You define a static property that depends on another static property declared later. Then you log both values. In production the first value becomes NaN, corrupting downstream calculations. Error logs show unexpected numbers, leading to wasted debugging time. Automated tests may miss it if they only check the second property. Comment A, B, C, or D with your reasoning. #typescript #programming #codinginterview #backend
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