Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 |
Tags
- 코테
- 코딩테스트
- Mesh
- LeetCode
- CS
- 컴퓨터공학
- adaptive remeshing
- 티스토리챌린지
- Database
- 데이터
- Data_Structure
- meshgraphnet
- code
- GNN
- DS
- 개발자
- mysql
- db
- 데이터베이스
- sort
- 오블완
- coding
- 대학생
- CNN
- SQL
- Python
- 컴퓨터사이언스
- 자료구조
- Leet Code
- 데베
Archives
- Today
- Total
sy1214ei 님의 블로그
[Leet Code] 747. Largest Number At Least Twice of Others - Python 본문
[Coding]
[Leet Code] 747. Largest Number At Least Twice of Others - Python
sy1214ei 2024. 11. 25. 03:21class Solution:
def dominantIndex(self, nums: List[int]) -> int:
sorted_nums = sorted(nums)
if sorted_nums[-1] >= sorted_nums[-2]*2:
for i in range(len(nums)):
if sorted_nums[-1] == nums[i]:
return i
else :
return -1
# Time Complexity : O(n)
# Space Complexity : O(n)

'[Coding]' 카테고리의 다른 글
| [Leet Code] 645. Set Mismatch - Python (0) | 2024.11.28 |
|---|---|
| [Leet Code] 58. Length of Last Word - Python (4) | 2024.11.26 |
| [Leet Code] 628. Maximum Product of Three Numbers - Python (0) | 2024.11.25 |
| [Leet Code] 594. Longest Harmonious Subsequence - Python (0) | 2024.11.25 |
| [Leet Code] 561. Array Partition (0) | 2024.11.25 |