problem_id int64 1.81k 2k | question stringlengths 176 3.77k | solutions stringlengths 292 1.21M | input_output stringclasses 1
value | difficulty stringclasses 1
value | url stringlengths 39 106 | starter_code stringlengths 65 1.4k |
|---|---|---|---|---|---|---|
1,805 | There are n people, each person has a unique id between 0 and n-1. Given the arrays watchedVideos and friends, where watchedVideos[i] and friends[i] contain the list of watched videos and the list of friends respectively for the person with id = i.
Level 1 of videos are all watched videos by your friends, level 2 of vi... | ["class Solution:\n def watchedVideosByFriends(self, watchedVideos: List[List[str]], friends: List[List[int]], id: int, level: int) -> List[str]:\n vis = [0 for i in range(len(friends))]\n index = id\n lis = set([id])\n while level>0:\n temp = []\n for i in lis:\n ... | interview | https://leetcode.com/problems/get-watched-videos-by-your-friends/ |
class Solution:
def watchedVideosByFriends(self, watchedVideos: List[List[str]], friends: List[List[int]], id: int, level: int) -> List[str]:
| |
1,806 | In a forest, each rabbit has some color. Some subset of rabbits (possibly all of them) tell you how many other rabbits have the same color as them. Those answers are placed in an array.
Return the minimum number of rabbits that could be in the forest.
Examples:
Input: answers = [1, 1, 2]
Output: 5
Explanation:
The t... | ["\n import re\n \n \n class Solution:\n def calc(self, a, b, op):\n if op == '+':\n for k, v in b.items():\n a[k] = a.get(k, 0) + v\n return a\n elif op == '-':\n for k, v in b.items():\n a[k] = a.get(k, 0) - v\n return... | interview | https://leetcode.com/problems/rabbits-in-forest/ |
class Solution:
def numRabbits(self, answers: List[int]) -> int:
| |
1,807 | Given an integer n, return a list of all simplified fractions between 0 and 1 (exclusive) such that the denominator is less-than-or-equal-to n. The fractions can be in any order.
Example 1:
Input: n = 2
Output: ["1/2"]
Explanation: "1/2" is the only unique fraction with a denominator less-than-or-equal-to 2.
Example ... | ["class Solution:\n arr = []\n \n def simplifiedFractions(self, n: int) -> List[str]:\n ans = []\n \n if len(Solution.arr) < 2:\n Solution.arr = [[],[]]\n \n if n >= len(Solution.arr):\n for d in range(len(Solution.arr), n + 1):\n deno... | interview | https://leetcode.com/problems/simplified-fractions/ |
class Solution:
def simplifiedFractions(self, n: int) -> List[str]:
| |
1,808 | Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.
Note:
You may assume the interval's end point is always bigger than its start point.
Intervals like [1,2] and [2,3] have borders "touching" but they don't overlap each other.
... | ["# Definition for an interval.\n # class Interval:\n # def __init__(self, s=0, e=0):\n # self.start = s\n # self.end = e\n \n class Solution:\n def eraseOverlapIntervals(self, intervals):\n \"\"\"\n :type intervals: List[Interval]\n :rtype: int\n \"\"\"\n ... | interview | https://leetcode.com/problems/non-overlapping-intervals/ |
class Solution:
def eraseOverlapIntervals(self, intervals: List[List[int]]) -> int:
| |
1,809 | Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].
Example:
Input: [1,2,3,4]
Output: [24,12,8,6]
Note: Please solve it without division and in O(n).
Follow up:
Could you solve it with constant space comple... | ["class Solution:\n def productExceptSelf(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: List[int]\n \"\"\"\n nums0 = nums.copy()\n son = 1\n if 0 in nums0:\n nums0.remove(0)\n for i in nums0:\n son *= i\n ... | interview | https://leetcode.com/problems/product-of-array-except-self/ |
class Solution:
def productExceptSelf(self, nums: List[int]) -> List[int]:
| |
1,810 | "Given an array of strings names of size n. You will create n folders in your file system such that,(...TRUNCATED) | "[\"class Solution:\\n def getFolderNames(self, names: List[str]) -> List[str]:\\n used, h(...TRUNCATED) | interview | https://leetcode.com/problems/making-file-names-unique/ |
class Solution:
def getFolderNames(self, names: List[str]) -> List[str]:
| |
1,811 | "Write a class StockSpanner which collects daily price quotes for some stock, and returns the span (...TRUNCATED) | "[\"class StockSpanner:\\n\\n def __init__(self):\\n self.s=[]\\n \\n\\n def nex(...TRUNCATED) | interview | https://leetcode.com/problems/online-stock-span/ | "\nclass StockSpanner:\n def __init__(self):\n def next(self, price: int) -> int:\n# Your Stoc(...TRUNCATED) | |
1,812 | "Implementing the class MajorityChecker, which has the following API:\n\nMajorityChecker(int[] arr) (...TRUNCATED) | "[\"from collections import defaultdict\\nfrom bisect import bisect_left, bisect_right\\n\\nclass Ma(...TRUNCATED) | interview | https://leetcode.com/problems/online-majority-element-in-subarray/ | "\nclass MajorityChecker:\n def __init__(self, arr: List[int]):\n def query(self, left: int, r(...TRUNCATED) | |
1,813 | "We have a sequence of books: the i-th book has thickness books[i][0] and height books[i][1].\nWe wa(...TRUNCATED) | "[\"class Solution:\\n def minHeightShelves(self, books: List[List[int]], shelf_width: int) -> in(...TRUNCATED) | interview | https://leetcode.com/problems/filling-bookcase-shelves/ | "\nclass Solution:\n def minHeightShelves(self, books: List[List[int]], shelf_width: int) -> int:(...TRUNCATED) | |
1,814 | "Given the running logs of n functions that are executed in a nonpreemptive single threaded CPU, fin(...TRUNCATED) | "[\"class Solution:\\n def exclusiveTime(self, n, logs):\\n \\\"\\\"\\\"\\n :typ(...TRUNCATED) | interview | https://leetcode.com/problems/exclusive-time-of-functions/ |
class Solution:
def exclusiveTime(self, n: int, logs: List[str]) -> List[int]:
|
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 7