The Invalid Tweets interview question is a practical database challenge. You are given a Tweets table containing an ID and the text of the tweet. Your task is to identify all tweets that are "invalid," which in this context means the length of the tweet content is strictly greater than 15 characters.
Companies like Twitter, Meta, and Microsoft use the Invalid Tweets coding problem to assess a candidate's basic SQL proficiency. It tests your knowledge of the LENGTH() or CHAR_LENGTH() functions and the use of the WHERE clause for filtering. It evaluation whether you can perform simple data validation tasks in a relational database.
This problem follows the SQL Filtering and String Measurement pattern.
tweet_id column.WHERE clause.LENGTH() returns the number of characters, but in some contexts, it might return bytes. Using CHAR_LENGTH() is often safer for UTF-8 characters.Tweets Table:
tweet_id 2.COUNT() instead of a string length function.>= 15 instead of > 15.SELECT * when only the ID was requested.Always check the specific SQL dialect (MySQL, PostgreSQL, T-SQL) mentioned in the interview. While LENGTH() is common, knowing when to use LEN() or CHAR_LENGTH() shows you understand the nuances of different Database interview patterns.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Combine Two Tables | Easy | Solve | |
| Fix Names in a Table | Easy | Solve | |
| Not Boring Movies | Easy | Solve | |
| Primary Department for Each Employee | Easy | Solve | |
| Queries Quality and Percentage | Easy | Solve |