Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- leetcode
- selenium
- Kaggle
- Keras
- Real or Not? NLP with Disaster Tweets
- AI 경진대회
- dacon
- 캐치
- Compas
- NLP 대회
- 우분투
- programmers
- 금융문자분석경진대회
- 인공지능 공모전
- 데이콘 소설
- 자연어처리
- 파이썬
- ubuntu
- windows
- 캐치카페
- catch
- Git
- hackerrank
- SW Expert Academy
- PYTHON
- 데이콘
- 백준
- 캐글
- Baekjoon
- 프로그래머스
- Today
- 1,010
- Total
- 441,434
솜씨좋은장씨
[leetCode] 83. Remove Duplicates from Sorted List (Python) 본문
Programming/코딩 1일 1문제
[leetCode] 83. Remove Duplicates from Sorted List (Python)
사용자 솜씨좋은장씨 2020. 12. 1. 16:56Given a sorted linked list, delete all duplicates such that each element appear only once.
Example 1:
Input: 1->1->2
Output: 1->2
Example 2:
Input: 1->1->2->3->3
Output: 1->2->3
Solution
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def deleteDuplicates(self, head: ListNode) -> ListNode:
list_values = []
while head != None:
list_values.append(head.val)
head = head.next
set_values = sorted(list(set(list_values)))
answerList = ListNode(0)
result = answerList
for num in set_values:
answerList.next = ListNode(num)
answerList = answerList.next
return result.next
SOMJANG/CODINGTEST_PRACTICE
1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.
github.com
'Programming > 코딩 1일 1문제' 카테고리의 다른 글
[leetCode] 744. Find Smallest Letter Greater Than Target (Python) (0) | 2020.12.05 |
---|---|
[leetCode] 82. Remove Duplicates from Sorted List II (Python) (0) | 2020.12.02 |
[leetCode] 83. Remove Duplicates from Sorted List (Python) (0) | 2020.12.01 |
[leetCode] 148. Sort List (Python) (0) | 2020.11.29 |
[leetCode] 468. Validate IP Address (Python) (0) | 2020.11.22 |
[leetCode] 338. Counting Bits (Pyhton) (0) | 2020.11.21 |
0 Comments