Welcome to my LeetCode solutions repository! This repository contains my solutions to various LeetCode problems, categorized by difficulty and topic. The solutions are implemented in multiple programming languages, including Python, Java, and SQL
To get started with the solutions, simply clone this repository to your local machine:
git clone https://github.com/rishimule/leetcode-solutions.gitEach solution is organized in a separate file named after the problem title, following this format:
<Problem_Title>.<language_extension>
/2191-sort-the-jumbled-numbers
├── 2191-sort-the-jumbled-numbers.py <!-- Example solution file for Sort the Jumbled Numbers problem in Python -->
├── README.md <!-- Problem Description -->
- Link: Sort the Jumbled Numbers problem in Python
- Description: You are given a 0-indexed integer array mapping which represents the mapping rule of a shuffled decimal system. mapping[i] = j means digit i should be mapped to digit j in this system. The mapped value of an integer is the new integer obtained by replacing each occurrence of digit i in the integer with mapping[i] for all 0 <= i <= 9. You are also given another integer array nums. Return the array nums sorted in non-decreasing order based on the mapped values of its elements.
class Solution:
def sortJumbled(self, mapping: List[int], nums: List[int]) -> List[int]:
def translate_integer(num: int) -> int:
digits: list[str] = list(str(num))
for i in range(len(digits)):
digits[i] = str(mapping[int(digits[i])])
return int("".join(digits))
number_mapping: dict[int, int] = {}
for num in nums:
number_mapping[num] = translate_integer(num)
nums.sort(key=lambda val: number_mapping[val])
return numsmapping = [8,9,4,0,2,1,3,5,7,6]
nums = [991,338,38]
s = Solution()
output = s.sortJumbled(mapping, nums)
print(output) # Output: [338, 38, 991] <!-- Expected output -->Contributions are welcome! If you have solved a problem that is not yet included in this repository, please feel free to submit a pull request with your solution.
This project is licensed under the MIT License - see the LICENSE file for details.
| 0133-clone-graph |
| 0011-container-with-most-water |
| 0611-valid-triangle-number |
| 1029-two-city-scheduling |
| 0139-word-break |
| 0139-word-break |
| 0004-median-of-two-sorted-arrays |
| 0153-find-minimum-in-rotated-sorted-array |
| 0268-missing-number |
| 0611-valid-triangle-number |
| 0875-koko-eating-bananas |
| 0078-subsets |
| 0136-single-number |
| 0268-missing-number |
| 0056-merge-intervals |
| 0242-valid-anagram |
| 0268-missing-number |
| 0347-top-k-frequent-elements |
| 0611-valid-triangle-number |
| 1029-two-city-scheduling |
| 2943-maximize-area-of-square-hole-in-grid |
| 0042-trapping-rain-water |
| 0155-min-stack |
| 0394-decode-string |
| 1047-remove-all-adjacent-duplicates-in-string |
| 1209-remove-all-adjacent-duplicates-in-string-ii |
| 1472-design-browser-history |
| 0042-trapping-rain-water |
| 0146-lru-cache |
| 0155-min-stack |
| 0380-insert-delete-getrandom-o1 |
| 1472-design-browser-history |
| 0380-insert-delete-getrandom-o1 |
| 0200-number-of-islands |
| 0063-unique-paths-ii |
| 0200-number-of-islands |
| 0695-max-area-of-island |
| 0994-rotting-oranges |
| 0146-lru-cache |
| 0430-flatten-a-multilevel-doubly-linked-list |
| 1472-design-browser-history |
| 3507-minimum-pair-removal-to-sort-array-i |
| 0003-longest-substring-without-repeating-characters |
| 0002-add-two-numbers |
| 0021-merge-two-sorted-lists |
| 0050-powx-n |
| 0394-decode-string |
| 1823-find-the-winner-of-the-circular-game |
| 0098-validate-binary-search-tree |
| 0235-lowest-common-ancestor-of-a-binary-search-tree |
| 1823-find-the-winner-of-the-circular-game |
| 1823-find-the-winner-of-the-circular-game |
| 3507-minimum-pair-removal-to-sort-array-i |
| 0347-top-k-frequent-elements |
| 3507-minimum-pair-removal-to-sort-array-i |
| 3507-minimum-pair-removal-to-sort-array-i |
| 3147-taking-maximum-energy-from-the-mystic-dungeon |
| 0004-median-of-two-sorted-arrays |
| 0347-top-k-frequent-elements |
| 0062-unique-paths |
| 0347-top-k-frequent-elements |
| 1347-minimum-number-of-steps-to-make-two-strings-anagram |
| 0039-combination-sum |
| 0078-subsets |
| 0128-longest-consecutive-sequence |
| 0695-max-area-of-island |
| 1472-design-browser-history |
| 0347-top-k-frequent-elements |
| 0347-top-k-frequent-elements |