This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;;;; functions.lisp | |
| ;;;; Random useful functions written with SBCL | |
| ;; 1 | |
| (defun countdown (x) | |
| "Recursively produces all positive integers less | |
| than or equal to x, a non-negative integer, in descending order" | |
| (cond ((< x 0) "negative integer") | |
| ((> x 0) (cons x (countdown(- x 1)))) | |
| (t nil))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Solution: | |
| def removeDuplicates(self, nums): | |
| """ | |
| :type nums: List[int] | |
| :rtype: int | |
| """ | |
| for i in reversed(range(len(nums))): | |
| if i > 0: | |
| if nums[i] == nums[i - 1]: | |
| del nums[i] |