question stringlengths 29 14k | solutions sequencelengths 1 6.39k | starter_code stringlengths 0 1.47k | input_output stringlengths 29 74M | difficulty stringclasses 6
values | raw_tags stringlengths 2 281 | name stringlengths 3 105 ⌀ | source stringclasses 10
values | tags stringlengths 2 183 | skill_types stringclasses 127
values | url stringlengths 36 138 ⌀ | time_limit stringclasses 143
values | date stringlengths 10 10 ⌀ | picture_num stringclasses 8
values | memory_limit stringclasses 28
values | Expected Time Complexity stringclasses 710
values | task_id int64 1 25.4k | solution_id int64 0 0 | solution stringlengths 6 413k | text stringlengths 123 413k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 1... | [
"class Solution:\n\n\tdef minimum_Number(self, s):\n\t\tl = list(s)\n\t\tl.sort()\n\t\tfor i in range(len(l)):\n\t\t\tif int(l[i]) > 0:\n\t\t\t\t(l[0], l[i]) = (l[i], l[0])\n\t\t\t\tbreak\n\t\tn = ''\n\t\tfor i in l:\n\t\t\tn += i\n\t\treturn n\n",
"class Solution:\n\n\tdef minimum_Number(self, s):\n\t\td = {}\n\... | #User function Template for python3
class Solution:
def minimum_Number(self, s):
# Code here | {"inputs": ["s = \"846903\"", "s = \"55010\""], "outputs": ["304689", "10055"]} | EASY | ['Algorithms', 'Mathematical'] | null | geeksforgeeks | ['Mathematics'] | [] | https://practice.geeksforgeeks.org/problems/smallest-number-by-rearranging-digits-of-a-given-number0820/1 | null | null | 0 | null | O(N * log(N)) where N is the number of digits of the given number | 6 | 0 | class Solution:
def minimum_Number(self, s):
l = list(s)
l.sort()
for i in range(len(l)):
if int(l[i]) > 0:
(l[0], l[i]) = (l[i], l[0])
break
n = ''
for i in l:
n += i
return n
| # Question
Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Ex... |
The number obtained by multiplying 1 by 2, 3, 5 several times (0 or more times) is called the Hamming numbers. For example
* 1
* 1 x 2 x 2 = 4
* 1 x 2 x 2 x 3 x 5 x 5 = 300
Etc. are humming numbers, but 11, 13, 14 etc. are not humming numbers.
All humming numbers are divisible by a power of 60 (for example, 54 is ... | [
"import sys\nfrom sys import stdin\nfrom bisect import bisect_right, bisect_left\nfrom math import ceil, log\ninput = stdin.readline\n\ndef main(args):\n\thammings = []\n\ttemp = set()\n\tfor i in range(ceil(log(1000000.0, 2)) + 1):\n\t\tfor j in range(ceil(log(1000000.0, 3)) + 1):\n\t\t\tfor k in range(ceil(log(10... | {"inputs": ["3 8\n2 27\n1 86\n0", "3 9\n2 27\n1 86\n0", "3 8\n1 35\n1 86\n0", "5 8\n2 27\n1 86\n0", "3 9\n4 27\n1 86\n0", "3 9\n6 27\n1 86\n0", "3 9\n6 31\n1 86\n0", "3 6\n6 31\n1 86\n0", "3 6\n6 9\n1 86\n0", "3 6\n8 9\n1 86\n0", "3 8\n1 19\n1 86\n0", "3 8\n2 27\n1 140\n0", "5 8\n2 27\n2 86\n0", "3 9\n4 15\n1 86\n0", "... | UNKNOWN_DIFFICULTY | [] | null | aizu | [] | [] | null | 1.0 seconds | null | null | 134.217728 megabytes | null | 5 | 0 | import sys
from sys import stdin
from bisect import bisect_right, bisect_left
from math import ceil, log
input = stdin.readline
def main(args):
hammings = []
temp = set()
for i in range(ceil(log(1000000.0, 2)) + 1):
for j in range(ceil(log(1000000.0, 3)) + 1):
for k in range(ceil(log(1000000.0, 5)) + 1):
a... | # Question
The number obtained by multiplying 1 by 2, 3, 5 several times (0 or more times) is called the Hamming numbers. For example
* 1
* 1 x 2 x 2 = 4
* 1 x 2 x 2 x 3 x 5 x 5 = 300
Etc. are humming numbers, but 11, 13, 14 etc. are not humming numbers.
All humming numbers are divisible by a power of 60 (for exa... | |
An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethe... | [
"def is_anagram(test, original):\n\treturn sorted(original.lower()) == sorted(test.lower())\n",
"from collections import Counter\n\ndef is_anagram(test, original):\n\treturn Counter(test.lower()) == Counter(original.lower())\n",
"def is_anagram(test, original):\n\treturn sorted(test.upper()) == sorted(original.... | def is_anagram(test, original):
| {"fn_name": "is_anagram", "inputs": [["foefet", "toffee"], ["Buckethead", "DeathCubeK"], ["Twoo", "WooT"], ["dumble", "bumble"], ["ound", "round"], ["apple", "pale"]], "outputs": [[true], [true], [true], [false], [false], [false]]} | EASY | ['Strings', 'Fundamentals'] | null | codewars | ['String algorithms', 'Fundamentals'] | [] | https://www.codewars.com/kata/529eef7a9194e0cbc1000255 | null | null | null | null | null | 8 | 0 | def is_anagram(test, original):
return sorted(original.lower()) == sorted(test.lower())
| # Question
An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
... |
Arkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value.
Arkady goes to the riverside each day and makes a mark on the side of the channel at the height of the water level, but if it coincides with a mark made before, no new mark is created. The water d... | [
"import sys\nn = int(input())\na = [int(x) for x in input().split(' ')]\nmaxm = 0\nidx = 0\nans = 0\nb = [0] * n\nfor i in range(n):\n\tif a[i] >= maxm:\n\t\tmaxm = a[i]\n\t\tidx = i\nfor i in range(idx, n):\n\tb[i] = maxm + 1\ni = idx - 1\nwhile i >= 0:\n\tb[i] = max(a[i] + 1, b[i + 1] - 1)\n\ti -= 1\nfor i in ran... | {"inputs": ["3\n0 1 1\n", "4\n0 0 1 2\n", "2\n0 0\n", "4\n0 1 1 0\n", "3\n0 1 0\n", "2\n0 1\n", "8\n0 0 2 0 3 0 3 2\n", "3\n0 1 2\n", "10\n0 0 2 2 3 2 3 3 1 3\n", "6\n0 0 0 2 0 1\n", "10\n0 1 2 0 4 5 3 6 0 5\n", "4\n0 0 1 1\n", "3\n0 0 0\n", "9\n0 1 0 1 1 4 0 4 8\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2... | MEDIUM_HARD | ['data structures', 'greedy', 'dp'] | null | codeforces | ['Dynamic programming', 'Data structures', 'Greedy algorithms'] | ['Dynamic programming', 'Data structures', 'Greedy algorithms'] | https://codeforces.com/problemset/problem/957/D | 1.0 seconds | null | null | 256.0 megabytes | null | 10 | 0 | import sys
n = int(input())
a = [int(x) for x in input().split(' ')]
maxm = 0
idx = 0
ans = 0
b = [0] * n
for i in range(n):
if a[i] >= maxm:
maxm = a[i]
idx = i
for i in range(idx, n):
b[i] = maxm + 1
i = idx - 1
while i >= 0:
b[i] = max(a[i] + 1, b[i + 1] - 1)
i -= 1
for i in range(1, n):
if b[i] < b[i - 1]:... | # Question
Arkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value.
Arkady goes to the riverside each day and makes a mark on the side of the channel at the height of the water level, but if it coincides with a mark made before, no new mark is created.... | |
Tom has finally taken over the business empire and now looking for
a new Name of the business to make a new start.
Joe (Tom's dear friend) suggested a string $S$ consisting of
Uppercase and lowercase letters
Tom wants to make some changes as per the following criteria:
1) String should $not$ have any vowels ... | [
"s = input().lower()\nvow = ['a', 'e', 'i', 'o', 'u', 'y']\nans = ''\nfor ch in s:\n\tif ch in vow:\n\t\tcontinue\n\tif ch.isalpha():\n\t\tans += '.' + ch\nprint(ans)\n"
] | {"inputs": [["CodeSprInT"]], "outputs": [[".c.d.s.p.r.n.t"]]} | UNKNOWN_DIFFICULTY | [] | null | codechef | [] | [] | https://www.codechef.com/SPRT2020/problems/EMPRNM | null | null | null | null | null | 12 | 0 | s = input().lower()
vow = ['a', 'e', 'i', 'o', 'u', 'y']
ans = ''
for ch in s:
if ch in vow:
continue
if ch.isalpha():
ans += '.' + ch
print(ans)
| # Question
Tom has finally taken over the business empire and now looking for
a new Name of the business to make a new start.
Joe (Tom's dear friend) suggested a string $S$ consisting of
Uppercase and lowercase letters
Tom wants to make some changes as per the following criteria:
1) String should $not$ have... | |
Dilpreet wants to paint his dog's home that has n boards with different lengths. The length of i^{th }board is given by arr[i] where arr[] is an array of n integers. He hired k painters for this work and each painter takes 1 unit time to paint 1 unit of the board.
The problem is to find the minimum time to get this jo... | [
"class Solution:\n\n\tdef minTime(self, arr, n, k):\n\n\t\tdef numofPainter(maxLen):\n\t\t\tpainters = 1\n\t\t\ttotal = 0\n\t\t\tfor board in arr:\n\t\t\t\ttotal += board\n\t\t\t\tif total > maxLen:\n\t\t\t\t\ttotal = board\n\t\t\t\t\tpainters += 1\n\t\t\treturn painters\n\t\t(low, high) = (max(arr), sum(arr))\n\t\... | #User function Template for python3
class Solution:
def minTime (self, arr, n, k):
#code here
| {"inputs": ["n = 5\nk = 3\narr[] = {5,10,30,20,15}", "n = 4\nk = 2\narr[] = {10,20,30,40}"], "outputs": ["35", "60"]} | MEDIUM_HARD | ['Algorithms', 'Searching', 'Binary Search', 'Divide and Conquer', 'Dynamic Programming'] | null | geeksforgeeks | ['Dynamic programming', 'Sorting', 'Divide and conquer', 'Complete search'] | ['Dynamic programming', 'Sorting', 'Complete search'] | https://practice.geeksforgeeks.org/problems/the-painters-partition-problem1535/1 | null | null | 0 | null | O(n log m) , m = sum of all boards' length | 7 | 0 | class Solution:
def minTime(self, arr, n, k):
def numofPainter(maxLen):
painters = 1
total = 0
for board in arr:
total += board
if total > maxLen:
total = board
painters += 1
return painters
(low, high) = (max(arr), sum(arr))
while low < high:
p = low + (high - low) // 2
cur... | # Question
Dilpreet wants to paint his dog's home that has n boards with different lengths. The length of i^{th }board is given by arr[i] where arr[] is an array of n integers. He hired k painters for this work and each painter takes 1 unit time to paint 1 unit of the board.
The problem is to find the minimum time to... |
There are $n$ candy boxes in front of Tania. The boxes are arranged in a row from left to right, numbered from $1$ to $n$. The $i$-th box contains $r_i$ candies, candies have the color $c_i$ (the color can take one of three values — red, green, or blue). All candies inside a single box have the same color (and it is ... | [
"INF = 10000000000.0\nmax_n = 50\nmax_k = 2000\n\ndef main():\n\t(n, s, k) = map(int, input().split())\n\ts -= 1\n\tbuf = [''] * (max_n + 1)\n\tdp = [[0 for i in range(max_n + 1)] for j in range(max_k + 1)]\n\tr = list(map(int, input().split()))\n\tc = input()\n\tanswer = INF\n\tfor i in range(len(c)):\n\t\tbuf[i] ... | {"inputs": ["5 3 10\n1 2 3 4 5\nRGBRR\n", "2 1 15\n5 6\nRG\n", "6 1 21\n4 2 3 5 1 6\nRGBGRB\n", "6 1 21\n6 5 4 3 2 1\nRGBRGB\n", "1 1 10\n10\nR\n", "2 1 10\n5 5\nRG\n", "2 1 10\n5 6\nRR\n", "5 3 10\n1 2 3 4 5\nRGBRG\n", "9 1 6\n1 1 1 3 3 3 2 2 2\nRGGBRRGBB\n", "50 39 2000\n48 43 26 24 46 37 15 30 39 34 4 14 29 34 8 18 ... | HARD | ['dp'] | null | codeforces | ['Dynamic programming'] | ['Dynamic programming'] | https://codeforces.com/problemset/problem/1057/C | null | 2019-12-31 | null | null | null | 1 | 0 | INF = 10000000000.0
max_n = 50
max_k = 2000
def main():
(n, s, k) = map(int, input().split())
s -= 1
buf = [''] * (max_n + 1)
dp = [[0 for i in range(max_n + 1)] for j in range(max_k + 1)]
r = list(map(int, input().split()))
c = input()
answer = INF
for i in range(len(c)):
buf[i] = c[i]
for i in range(k, -1... | # Question
There are $n$ candy boxes in front of Tania. The boxes are arranged in a row from left to right, numbered from $1$ to $n$. The $i$-th box contains $r_i$ candies, candies have the color $c_i$ (the color can take one of three values — red, green, or blue). All candies inside a single box have the same color... | |
If you visit Aizu Akabeko shrine, you will find a unique paper fortune on which a number with more than one digit is written.
Each digit ranges from 1 to 9 (zero is avoided because it is considered a bad omen in this shrine). Using this string of numeric values, you can predict how many years it will take before your ... | [
"def sub(maxs, mins):\n\tfor i in range(len(maxs)):\n\t\tif maxs[i] != mins[i]:\n\t\t\tif i == len(maxs) - 1:\n\t\t\t\treturn int(maxs[i]) - int(mins[i])\n\t\t\tif i == len(maxs) - 2:\n\t\t\t\treturn int(maxs[i:i + 2]) - int(mins[i:i + 2])\n\t\t\treturn 10\n\treturn 0\n\ndef checkEqual(S):\n\tans = 8\n\tfor k in ra... | {"inputs": ["9714431", "16612328", "23422731", "754526", "955577", "75547", "2112", "799", "88", "32523857", "4787", "1859551", "135661", "3675", "156692", "167918384", "83994", "4837847", "14513597", "15282598", "12659326", "1468417", "6280", "115464", "52376853", "2315", "3641224", "97187", "836", "195884", "36250", ... | UNKNOWN_DIFFICULTY | [] | null | aizu | [] | [] | null | 1.0 seconds | null | null | 268.435456 megabytes | null | 3 | 0 | def sub(maxs, mins):
for i in range(len(maxs)):
if maxs[i] != mins[i]:
if i == len(maxs) - 1:
return int(maxs[i]) - int(mins[i])
if i == len(maxs) - 2:
return int(maxs[i:i + 2]) - int(mins[i:i + 2])
return 10
return 0
def checkEqual(S):
ans = 8
for k in range(1, len(S)):
if len(S) % k != 0:
... | # Question
If you visit Aizu Akabeko shrine, you will find a unique paper fortune on which a number with more than one digit is written.
Each digit ranges from 1 to 9 (zero is avoided because it is considered a bad omen in this shrine). Using this string of numeric values, you can predict how many years it will take ... | |
"You have a deck of $n$ cards, and you'd like to reorder it to a new one.\n\nEach card has a value b(...TRUNCATED) | ["import heapq\nfrom math import sqrt\nimport operator\nimport sys\ninf_var = 0\nif inf_var == 1:\n\(...TRUNCATED) | "{\"inputs\": [\"4\\n4\\n1 2 3 4\\n5\\n1 5 2 4 3\\n6\\n4 2 5 3 6 1\\n1\\n1\\n\", \"4\\n4\\n2 1 3 4\\(...TRUNCATED) | EASY | ['data structures', 'greedy', 'math'] | null | codeforces | ['Data structures', 'Mathematics', 'Greedy algorithms'] | ['Data structures', 'Greedy algorithms'] | https://codeforces.com/problemset/problem/1492/B | 1 second | 2021-02-23 | 0 | 512 megabytes | null | 4 | 0 | "import heapq\nfrom math import sqrt\nimport operator\nimport sys\ninf_var = 0\nif inf_var == 1:\n\t(...TRUNCATED) | "# Question\n\nYou have a deck of $n$ cards, and you'd like to reorder it to a new one.\n\nEach card(...TRUNCATED) | |
"Given a string 's'. The task is to find the smallest window length that contains all the characters(...TRUNCATED) | ["class Solution:\n\n\tdef findSubString(self, str):\n\t\tdict = {}\n\t\tans = float('inf')\n\t\tj =(...TRUNCATED) | "#User function Template for python3\n\n\n\nclass Solution:\n\n def findSubString(self, str):\n\n(...TRUNCATED) | "{\"inputs\": [\"\\\"AABBBCBBAC\\\"\", \"\\\"aaab\\\"\", \"\\\"GEEKSGEEKSFOR\\\"\"], \"outputs\": [\(...TRUNCATED) | MEDIUM | ['Algorithms', 'Hash', 'sliding-window', 'Strings', 'Data Structures', 'Arrays'] | null | geeksforgeeks | ['String algorithms', 'Data structures', 'Amortized analysis'] | ['Amortized analysis', 'Data structures'] | https://practice.geeksforgeeks.org/problems/smallest-distant-window3132/1 | null | null | 0 | null | O(256.N) | 14 | 0 | "class Solution:\n\n\tdef findSubString(self, str):\n\t\tdict = {}\n\t\tans = float('inf')\n\t\tj = (...TRUNCATED) | "# Question\n\nGiven a string 's'. The task is to find the smallest window length that contains all (...TRUNCATED) |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 7