repo stringclasses 1
value | func_name stringclasses 5
values | docstring stringclasses 5
values | code stringclasses 5
values | url float64 |
|---|---|---|---|---|
interview/common | reverse_string | Given a string, return it reversed. | def reverse_string(s):
return s[::-1] | null |
interview/common | is_palindrome | Check if a string is a palindrome. | def is_palindrome(s):
return s == s[::-1] | null |
interview/common | fibonacci | Return the nth Fibonacci number. | def fibonacci(n):
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
return a | null |
interview/common | factorial | Return the factorial of a number. | def factorial(n):
return 1 if n == 0 else n * factorial(n - 1) | null |
interview/common | two_sum | Return indices of the two numbers such that they add up to target. | def two_sum(nums, target):
lookup = {}
for i, num in enumerate(nums):
if target - num in lookup:
return [lookup[target - num], i]
lookup[num] = i | null |
interview/common | reverse_string | Given a string, return it reversed. | def reverse_string(s):
return s[::-1] | null |
interview/common | is_palindrome | Check if a string is a palindrome. | def is_palindrome(s):
return s == s[::-1] | null |
interview/common | fibonacci | Return the nth Fibonacci number. | def fibonacci(n):
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
return a | null |
interview/common | factorial | Return the factorial of a number. | def factorial(n):
return 1 if n == 0 else n * factorial(n - 1) | null |
interview/common | two_sum | Return indices of the two numbers such that they add up to target. | def two_sum(nums, target):
lookup = {}
for i, num in enumerate(nums):
if target - num in lookup:
return [lookup[target - num], i]
lookup[num] = i | null |
interview/common | reverse_string | Given a string, return it reversed. | def reverse_string(s):
return s[::-1] | null |
interview/common | is_palindrome | Check if a string is a palindrome. | def is_palindrome(s):
return s == s[::-1] | null |
interview/common | fibonacci | Return the nth Fibonacci number. | def fibonacci(n):
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
return a | null |
interview/common | factorial | Return the factorial of a number. | def factorial(n):
return 1 if n == 0 else n * factorial(n - 1) | null |
interview/common | two_sum | Return indices of the two numbers such that they add up to target. | def two_sum(nums, target):
lookup = {}
for i, num in enumerate(nums):
if target - num in lookup:
return [lookup[target - num], i]
lookup[num] = i | null |
interview/common | reverse_string | Given a string, return it reversed. | def reverse_string(s):
return s[::-1] | null |
interview/common | is_palindrome | Check if a string is a palindrome. | def is_palindrome(s):
return s == s[::-1] | null |
interview/common | fibonacci | Return the nth Fibonacci number. | def fibonacci(n):
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
return a | null |
interview/common | factorial | Return the factorial of a number. | def factorial(n):
return 1 if n == 0 else n * factorial(n - 1) | null |
interview/common | two_sum | Return indices of the two numbers such that they add up to target. | def two_sum(nums, target):
lookup = {}
for i, num in enumerate(nums):
if target - num in lookup:
return [lookup[target - num], i]
lookup[num] = i | null |
interview/common | reverse_string | Given a string, return it reversed. | def reverse_string(s):
return s[::-1] | null |
interview/common | is_palindrome | Check if a string is a palindrome. | def is_palindrome(s):
return s == s[::-1] | null |
interview/common | fibonacci | Return the nth Fibonacci number. | def fibonacci(n):
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
return a | null |
interview/common | factorial | Return the factorial of a number. | def factorial(n):
return 1 if n == 0 else n * factorial(n - 1) | null |
interview/common | two_sum | Return indices of the two numbers such that they add up to target. | def two_sum(nums, target):
lookup = {}
for i, num in enumerate(nums):
if target - num in lookup:
return [lookup[target - num], i]
lookup[num] = i | null |
interview/common | reverse_string | Given a string, return it reversed. | def reverse_string(s):
return s[::-1] | null |
interview/common | is_palindrome | Check if a string is a palindrome. | def is_palindrome(s):
return s == s[::-1] | null |
interview/common | fibonacci | Return the nth Fibonacci number. | def fibonacci(n):
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
return a | null |
interview/common | factorial | Return the factorial of a number. | def factorial(n):
return 1 if n == 0 else n * factorial(n - 1) | null |
interview/common | two_sum | Return indices of the two numbers such that they add up to target. | def two_sum(nums, target):
lookup = {}
for i, num in enumerate(nums):
if target - num in lookup:
return [lookup[target - num], i]
lookup[num] = i | null |
interview/common | reverse_string | Given a string, return it reversed. | def reverse_string(s):
return s[::-1] | null |
interview/common | is_palindrome | Check if a string is a palindrome. | def is_palindrome(s):
return s == s[::-1] | null |
interview/common | fibonacci | Return the nth Fibonacci number. | def fibonacci(n):
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
return a | null |
interview/common | factorial | Return the factorial of a number. | def factorial(n):
return 1 if n == 0 else n * factorial(n - 1) | null |
interview/common | two_sum | Return indices of the two numbers such that they add up to target. | def two_sum(nums, target):
lookup = {}
for i, num in enumerate(nums):
if target - num in lookup:
return [lookup[target - num], i]
lookup[num] = i | null |
interview/common | reverse_string | Given a string, return it reversed. | def reverse_string(s):
return s[::-1] | null |
interview/common | is_palindrome | Check if a string is a palindrome. | def is_palindrome(s):
return s == s[::-1] | null |
interview/common | fibonacci | Return the nth Fibonacci number. | def fibonacci(n):
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
return a | null |
interview/common | factorial | Return the factorial of a number. | def factorial(n):
return 1 if n == 0 else n * factorial(n - 1) | null |
interview/common | two_sum | Return indices of the two numbers such that they add up to target. | def two_sum(nums, target):
lookup = {}
for i, num in enumerate(nums):
if target - num in lookup:
return [lookup[target - num], i]
lookup[num] = i | null |
interview/common | reverse_string | Given a string, return it reversed. | def reverse_string(s):
return s[::-1] | null |
interview/common | is_palindrome | Check if a string is a palindrome. | def is_palindrome(s):
return s == s[::-1] | null |
interview/common | fibonacci | Return the nth Fibonacci number. | def fibonacci(n):
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
return a | null |
interview/common | factorial | Return the factorial of a number. | def factorial(n):
return 1 if n == 0 else n * factorial(n - 1) | null |
interview/common | two_sum | Return indices of the two numbers such that they add up to target. | def two_sum(nums, target):
lookup = {}
for i, num in enumerate(nums):
if target - num in lookup:
return [lookup[target - num], i]
lookup[num] = i | null |
interview/common | reverse_string | Given a string, return it reversed. | def reverse_string(s):
return s[::-1] | null |
interview/common | is_palindrome | Check if a string is a palindrome. | def is_palindrome(s):
return s == s[::-1] | null |
interview/common | fibonacci | Return the nth Fibonacci number. | def fibonacci(n):
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
return a | null |
interview/common | factorial | Return the factorial of a number. | def factorial(n):
return 1 if n == 0 else n * factorial(n - 1) | null |
interview/common | two_sum | Return indices of the two numbers such that they add up to target. | def two_sum(nums, target):
lookup = {}
for i, num in enumerate(nums):
if target - num in lookup:
return [lookup[target - num], i]
lookup[num] = i | null |
No dataset card yet
- Downloads last month
- 2