Example Of Deque Datastructure In Python

Lessons from Leet Code Puzzles

Pavol Kutaj
Apr 25, 2022

The aim of this page📝is to learn about the use of deque data structure in Python by the example of 1556. Thousand Separator — LeetCode puzzle.

1. PUZZLE

Given an integer n, add a dot (“.”) as the thousands separator and return it in string format.

Example 1:

Input: n = 987
Output: "987"
Example 2:

Input: n = 1234
Output: "1.234"

2. CODE

3. RUBBERDUCK

4. RESULT

Runtime: 35 ms, faster than 70.19% of Python3 online submissions for Thousand Separator. Memory Usage: 13.9 MB, less than 60.56% of Python3 online submissions for Thousand Separator.

--

--

No responses yet