Skip to content

feat: add solution to lc problem: No. 0395 #782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 3, 2022
Merged

Conversation

pranay999000
Copy link
Contributor

No description provided.

@yanglbme
Copy link
Member

yanglbme commented Apr 2, 2022

Hi @pranay999000 , I'll review the pull request within 24 hours. Thanks.

@yanglbme yanglbme self-assigned this Apr 2, 2022
@yanglbme
Copy link
Member

yanglbme commented Apr 3, 2022

Thanks for your contribution. I'll format your code before merging into main branch. @pranay999000

@yanglbme yanglbme merged commit 39a782c into doocs:main Apr 3, 2022
@yanglbme
Copy link
Member

yanglbme commented Apr 3, 2022

if (counter.containsKey(r))
    counter.put(r, counter.get(r) + 1);
else
    counter.put(r, 1);
if (counter.containsKey(l))
    counter.put(l, counter.get(l) - 1);
else
    counter.put(l, 1);

we can use getOrDeault() in map, e.g.

counter.put(r, counter.getOrDefault(r, 0) + 1);
counter.put(l, counter.getOrDefault(l, 2) - 1);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants