난이도: EASY
문제
Table: Tweets
+----------------+---------+
| Column Name | Type |
+----------------+---------+
| tweet_id | int |
| content | varchar |
+----------------+---------+
tweet_id is the primary key (column with unique values) for this table.
content consists of characters on an American Keyboard, and no other special characters.
This table contains all the tweets in a social media app.
Write a solution to find the IDs of the invalid tweets. The tweet is invalid if the number of characters used in the content of the tweet is strictly greater than 15.
Return the result table in any order.
The result format is in the following example.
Example 1:
Input: Tweets table
+----------+-----------------------------------+
| tweet_id | content |
+----------+-----------------------------------+
| 1 | Let us Code |
| 2 | More than fifteen chars are here! |
+----------+-----------------------------------+
Output:
+----------+
| tweet_id |
+----------+
| 2 |
+----------+
Explanation:
Tweet 1 has length = 11. It is a valid tweet.
Tweet 2 has length = 33. It is an invalid tweet.
주요 함수
LENGTH(컬럼명)
: 컬럼 값의 길이 반환
LENGTHB() vs LENGTH() 차이
- LENGTH(컬럼명): 문자의 개수(영문, 한글 모두 1자로 계산)
- LENGTHB(컬럼명): 바이트 수(영문 1바이트, 한글 2~3바이트)
UTF-8 환경에서 한글을 포함한 문자열의 바이트 길이를 기준으로 조건을 주고 싶다면 LENGTHB()를 사용.
나의 최종 제출 답안:
SELECT tweet_id
FROM Tweets
WHERE LENGTH(content) > 15
'Coding Challenges > LeetCode' 카테고리의 다른 글
[Java] 26. Remove Duplicates from Sorted Array (0) | 2025.02.10 |
---|---|
[SQL50] 1148. Article Views I (0) | 2025.02.10 |
[Java] 21. Merge Two Sorted Lists (1) | 2025.02.07 |
[SQL50] 595. Big Countries (0) | 2025.02.07 |
[SQL50] 584. Find Customer Referee (1) | 2025.02.07 |