Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 77980

Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability. Use the python tag for all Python related questions. If you believe your question may be even more specific, you can include a version specific tag such as python-3.x.

4 votes
Accepted

Top 2 most common elements inside array in Python

If you're okay with using the built-in collections module, I'd suggest the following. collections.Counter is ideally suited for this and will make the problem trivial. from collections import Counter …
Daniel Lenz's user avatar
7 votes

"Longest Substring Without Repeating Characters" in Python

Nice solution, please find a few thoughts below: Do you need to wrap it in class for leetcode? It's unnecessary otherwise. Function names use snake_case and not camelCase, check PEP8 for more detail …
Daniel Lenz's user avatar
3 votes

Getting a key's value in a nested dictionary

Nice recursive solution! Just a few suggestions: You should structure you entire code better and set up individual functions to set up the menu and get the prices, not do it all in main. Ideally, yo …
Daniel Lenz's user avatar
2 votes
Accepted

Sum of diagonal elements in a matrix

The algorithm that you have implemented right now just raises an IndexError. I'll suggest a slightly different way to do is that will have O(n) speed and O(1) memory, where n is the side length of th …
Daniel Lenz's user avatar
3 votes
2 answers
780 views

Temporary modifying env variables with context manager

One function of a program I'm working with benefits from using all available openMP threads. The rest of the program has issues with the env variable OMP_NUM_THREADS being unequal to 1. I'm currently …
Daniel Lenz's user avatar
3 votes
Accepted

LinkedList class implementation in Python

Great job, looks really good! A few minor thoughts, on top of the existing answers: class LinkedList(object): ... You don't need to explicitly inherit from object if you're writing python3 code …
Daniel Lenz's user avatar