Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

New answers tagged

4 votes
Accepted

Implement a Python frozenmap

Library code cannot resort to global variable hacks. You are attempting to implement a data structure. That's a bedrock kind of library code. As such, it cannot resort to crazy mechanisms like setting ...
user avatar
  • 9,615
3 votes
Accepted

How do I increase the memory efficiency of this longest substring implementation? (C++)

Use a std::bitset A std::unordered_map is inappropriate here. First of all, it stores keys and values, but you are not ...
user avatar
  • 32.6k
2 votes

Sudoku puzzle solver for Leetcode

Your rotateBoard() method is merely performing "transposition" upon an indexed array of rows. This is a subject that I have somewhat recently conducted ...
user avatar
  • 7,616
1 vote

Porting PHP's array_push to Python

Some points to supplement @FMc's answer (though we'll put aside for the moment its excellent advice against mutation): The way you compute keys when extending dictionaries can be tidied with ...
user avatar
  • 533
4 votes

Porting PHP's array_push to Python

The list case. As noted in a comment, you can simplify to this: array.extend(args) The dict case. It looks like the goal is to find the max integer key, if any, ...
user avatar
  • 9,615

Top 50 recent answers are included