O83

Design Twitter Feed

Mid / Senior Engineer
Target Time: 25 - 35 Minutes
Type: ARRAY

Problem Statement & Objective

Design a simplified version of Twitter where users can post tweets, follow/unfollow another user, and see the 10 most recent tweets in the user's news feed.

Function Signature (Python)

design_twitter_feed(operations: list) -> list

Input & Output Contract

Output Rule:Sıralı işlem çıktıları (None veya int listesi).

System Constraints

1 <= islemler.length <= 1000
1 <= userId, followerId, followeeId, tweetId <= 500
Kullanıcı kendisini takipten çıkaramaz/takip edemez

Example Execution Walkthrough

islemler = [['post_tweet', 1, 5], ['get_news_feed', 1], ['follow', 1, 2], ['post_tweet', 2, 6], ['get_news_feed', 1], ['unfollow', 1, 2], ['get_news_feed', 1]]
Cevap: [None, [5], None, None, [6, 5], None, [5]]

Example Test Scenarios (3)

Example 1: Basic Flow
Input:[[["post_tweet",1,5],["get_news_feed",1],["follow",1,2],["post_tweet",2,6],["get_news_feed",1],["unfollow",1,2],["get_news_feed",1]]]
Expected Output:[null,[5],null,null,[6,5],null,[5]]
Example 2: Yeniden Eskiye Sıralama
Input:[[["post_tweet",1,101],["post_tweet",1,102],["get_news_feed",1]]]
Expected Output:[null,null,[102,101]]
Example 3: Boş Akış
Input:[[["get_news_feed",99]]]
Expected Output:[[]]
Loading Python Editor...
Input Parameters
[
  [
    [
      "post_tweet",
      1,
      5
    ],
    [
      "get_news_feed",
      1
    ],
    [
      "follow",
      1,
      2
    ],
    [
      "post_tweet",
      2,
      6
    ],
    [
      "get_news_feed",
      1
    ],
    [
      "unfollow",
      1,
      2
    ],
    [
      "get_news_feed",
      1
    ]
  ]
]
Expected Output
[
  null,
  [
    5
  ],
  null,
  null,
  [
    6,
    5
  ],
  null,
  [
    5
  ]
]