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 twoSum(self, nums: List[int], target: int) -> List[int]: | |
| for i in range(len(nums)): | |
| for j in range(len(nums[1:])): | |
| if nums[i] + nums[j] == target and i != j: | |
| return [i, j] |
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 twoSum(self, nums: List[int], target: int) -> List[int]: | |
| hashmap = {} | |
| for i in range(len(nums)): | |
| complement = target - nums[i] | |
| if complement in hashmap: | |
| return [hashmap[complement], i] | |
| hashmap[nums[i]] = i |
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
| # Definition for singly-linked list. | |
| # class ListNode: | |
| # def __init__(self, val=0, next=None): | |
| # self.val = val | |
| # self.next = next | |
| class Solution: | |
| def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]: | |
| cur = head | |
| prev = None | |
| while cur: |
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
| # Definition for singly-linked list. | |
| # class ListNode: | |
| # def __init__(self, val=0, next=None): | |
| # self.val = val | |
| # self.next = next | |
| class Solution: | |
| def reverseList(self, head: ListNode) -> ListNode: | |
| if not head: | |
| return head | |
| if not head.next: |
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
| from typing import Dict | |
| from collections import Counter | |
| def most_frequent_char(s: str) -> Dict: | |
| mapping = Counter(s) | |
| return dict(sorted(mapping.items(), key=lambda item: item[1])) |
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
| Fn::ForEach::UniqueLoopName: | |
| - Identifier | |
| - - Value1 //collection | |
| - Value2 | |
| - 'OutputKey': | |
| OutputValue | |
| Fn::ForEach::UniqueLoopName: | |
| - Identifier | |
| - !Ref ListOfValues |
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
| AWSTemplateFormatVersion: '2010-09-09' | |
| Transform: 'AWS::LanguageExtensions' | |
| Parameters: | |
| QueueNames: | |
| Type: CommaDelimitedList | |
| Description: A list of SQS queue Names. | |
| Default: 'queue-1, queue-2, queue-3' | |
| Resources: | |
| Fn::ForEach::Subscription: | |
| - QueueName |
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
| AWSTemplateFormatVersion: '2010-09-09' | |
| Resources: | |
| queue1: | |
| Type: AWS::SQS::Queue | |
| Properties: | |
| QueueName: "queue1" | |
| queue2: | |
| Type: AWS::SQS::Queue | |
| Properties: | |
| QueueName: "queue2" |