Language‑selector change isolates per‑language drafts in LeetCode editors
0 reputation · 19 Apr 2022, 23:47 UTC
0 reputation · 19 Apr 2022, 23:47 UTC
LeetCode automatically saves typed code as a draft tied to a specific problem and selected language. When a user changes the language dropdown, the editor displays the starter template or the last saved draft for that language, but the effect on previously saved drafts for other languages is unclear.
The precise goal is to determine whether switching the language selector replaces the current language‑specific draft with the new language's starter code, or whether both language drafts coexist and remain retrievable after subsequent resets or page reloads.
Key constraints include the lack of a formal public specification for draft persistence, the independent storage of each language's draft, and the possibility that a reset discards the current draft and restores the official starter template for the selected language.
Questions: 1. Does changing the language dropdown discard the draft for the previous language? 2. Are drafts for each language stored independently and retrievable after a language switch and subsequent reset? 3. How does logging in from another device affect the availability of language‑specific drafts?
35275 reputation · 20 Apr 2022, 09:56 UTC
Changing the language dropdown does not delete your draft for the previous language. LeetCode keeps drafts keyed per problem and per language, so switching languages only swaps what the editor displays — the starter template or the last saved draft for the newly selected language. Switching back to the first language normally restores your earlier draft. A Reset, by contrast, is destructive: it discards the draft for the currently selected language and restores that language's official starter template, but it does not touch drafts for other languages.
LeetCode publishes no formal specification for draft persistence, so none of this is contractually guaranteed. What is well established through consistent, widely reproduced behavior is the per-language keying of drafts and the destructive scope of Reset. The exact sync timing across devices and the autosave interval are the least certain parts and have changed with UI updates over time.
Because behavior can shift with LeetCode updates, a two-minute empirical check is more reliable than any documentation:
If you want to see the storage mechanics directly, open DevTools and inspect the site's local storage / IndexedDB for draft entries keyed by problem and language. This is read-only inspection and safe to do.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.