question_id int64 700k 876k | question_title stringlengths 3 81 | question_content stringlengths 131 2.51k | dataset stringclasses 1
value | difficulty stringclasses 3
values | java dict | python dict | test_cases stringlengths 200 208M |
|---|---|---|---|---|---|---|---|
700,218 | Directed Graph Cycle | Given a Directed Graph with V vertices (Numbered from 0 to V-1) and E edges, check whether it contains any cycle or not.
Examples:
Input:
Output:
1
Explanation:
3 -> 3 is a cycle
Input:
Output:
0
Explanation:
no cycle in the graph
Constraints:
1 ≤ V, E ≤ 10**5 | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public boolean isCyclic(int V, ArrayList<ArrayList<Integer>> adj)"
],
"initial_code": "import java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass DriverClass {\n public static void main(String[] args) {\n S... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"isCyclic(self, V : int , adj : List[List[int]]) -> bool"
],
"initial_code": "# Initial Template for Python 3\n\nimport sys\n\nsys.setrecursionlimit(10**6)\n\nif __name__ == '__main__':\n t = int(input())\n for i in range... | eJzVVUFOwzAQ5MCBZ6x8rpDXjp2ElyCxiAPkwMX0kEpICMQj4HHceArerREqrakdglB7SqPZnfXMevJ8/Pp+ciS/87f4cPGgbsNyNaozUEjBgaegIT4hGAoGLAULDYWG3xnQagFquF8O1+Nwc3W3Gr9KnyioxwVs9sPYy+U6usTnoaXQQkehg55CD5oh8lcglmsFYirpO0BdyK7TGS34SpKWG+zjqBWu35pc/6ibZbCd4I5JLJpZcK11w3xOtGC+lvk65hN3vOjKzG4CH07ZhqbaeXSA2VXOUrHmaUhE0QYNIGtiAWMpSm1bLbSJ6tZf... |
704,571 | Incomplete Array | Given an array A containing N integers.Find out how many elements should be added such that all elements between the maximum and minimum of the array is present in the array.
Examples:
Input:
N=5
A=[205,173,102,324,957]
Output:
851
Explanation:
The maximum and minimum of given
array is 957 and 102 respectively.We n... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int countElements(int N, int A[])"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedRea... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"countElements(self,N,A)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n\n for _ in range(t):\n N = int(input())\n A = list(map(int, input().strip().sp... | eJzVlsFuFDEMhjlw4imsOVcodpKJ0xs3HgGJIg6wBy5LD1sJCRXxEPC++P9nOYDkstpSFUbyp9XEcfxn7GS/Pv3+8tkTPq9exI/Xn5cP++ubw3Ipi17ttcDiEVDJSnbSySlzzgF0oAFluZBl9+l69+6we//2483hZ9CI+OVqv9xeyG9LdRiXChpZyUE6qBzVSKRhMXCSThrJUed7H2SazEiSMeiWKk26rAKVogguuoq6WBEzsSa2irnUItWkNqk9W6hnC3UYVBu1GLWAg1zJTlbSSPo733sjOeocdSXpMxhzMOZgtEH/Qf9B/0H/Qf+V... |
703,864 | Maximum bitonic subarray sum | Given an array arr[] of integers, the task is to find the maximum sum of a bitonic subarray. A bitonic subarray is one in which the elements first increase, may stay the same, and then decrease. A strictly increasing or strictly decreasing subarray is also considered a bitonic subarray.Examples:
Examples:
Input:
arr[] ... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1617815347,
"func_sign": [
"public long maxSumBitonicSubArr(int[] arr)"
],
"initial_code": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int t = scann... | {
"class_name": "Solution",
"created_at_timestamp": 1617815347,
"func_sign": [
"maxSumBitonicSubArr(self, arr)"
],
"initial_code": "def main():\n t = int(input())\n for _ in range(t):\n arr = list(map(int, input().split()))\n solution = Solution()\n print(solution.maxSumBitonicS... | eJylVUtOwzAQZYHENUZZV8jjXxJOgkQRC+iCTWHRSkgIxCHgkuy4AW9spzStxqGtpXlJnJnn+WXycf71c3GW1vU3bm5em8fl83rVXFHD8yUbLOqxBDqBViAKBGKy5MhTaGbULF6eF/erxcPd03pVGAJs4nz5Pl82bzMaUzvYsthShHjKz2wUKscKz8aHEc+wx/CeOmopai4Gjdek2GuXfkhMzkxOTc5Nr6UkaWtn7vtfnhUyW3GeLMRBPCRAIqSFdOJ5CYJYNFlU2W3ueHjbF/W2mIdC5wo9lBTPOMJ2smJ/VcehOBxOEPuENu2Yf6eC... |
700,910 | Sum the common elements | You are given two arrays of size n1 and n2. Your task is to find all the elements that are common to both the arrays and sum them. If there are no common elements the output would be 0.
Examples:
Input:
5 6
1 2 3 4 5
2 3 4 5 6 7
Output:
14
Explanation:
Common unique elements in both arrays are 2, 3, 4 and 5 so answe... | geeksforgeeks | Easy | {
"class_name": "Geeks",
"created_at_timestamp": 1615292571,
"func_sign": [
"public\n static int commonSum(int n1, int n2, int arr1[], int arr2[])"
],
"initial_code": "// Initial Template for Java\n\nimport java.util.*;\n\nclass GFG {\npublic\n static void main(String[] args) {\n Scanner sc = new Sca... | {
"class_name": "Solution",
"created_at_timestamp": 1688553429,
"func_sign": [
"commonSum(self,n1,n2,arr1,arr2)"
],
"initial_code": "if __name__ == '__main__':\n for _ in range(int(input())):\n n1, n2 = map(int, input().split())\n arr1 = list(map(int, input().split()))\n arr2 = lis... | eJytVDFOxDAQpIB/jFyf0NqOnYSXIGFEASlozBU5CQmBeAQ8jI7nsJvkxHGwl3OE0zi2d2Z3xt7X0/fPs5NhXH7w5OrJ3Of1pjcXMDZlQkg55YgaDVpYMiuY7nHd3fbd3c3Dpp+OUsovKZvnFX7GB4m3mL6dqYJjD+IQHMETKk6LGSOhJjSEljiz0tQiokAKpoAKqsASInHI3gITCZPGYRvSaOpRAY/AGrKCXLtP2aFCZEmLBbVSqgA6hqwY9NuaYbPln5oXA296PqQJHYJGIDYxVnFiU5xGqMU5uMGGaQhKux1whWAeftJG5nr18a94... |
713,136 | GCD Array | You are given an array, arrof lengthN,and also a single integerK. Your task is to split the array arrintoKnon-overlapping, non-empty subarrays. For each of the subarrays, you calculate the sum of the elements in it. Let us denote these sums as S1, S2,S3, ...,SK. Where Si denotes the sum of the elements in the i**thsuba... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1671443925,
"func_sign": [
"public static int solve(int N, int K, int[] arr)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\nclass IntArray\n{\n public static int[] input(BufferedReader br, int n) throws IOException\n {\n String... | {
"class_name": "Solution",
"created_at_timestamp": 1671443925,
"func_sign": [
"solve(self, N : int, K : int, arr : List[int]) -> int"
],
"initial_code": "class IntArray:\n def __init__(self) -> None:\n pass\n\n def Input(self, n):\n arr = [int(i) for i in input().strip().split()] # a... | eJztm8GuZDcVRRnwIVaPI+Rj+9g+TPgNJBoxgAyYNAwSCQmBMuMH4H9Z+9hVA1ARIjoKgkLpbqQ+VV3P6/p673Xf++bHf/vLz36U//v5N/yfX/zxw28//f7rrz78tHywj5+sfvzkHz/1MksUa8W82C7NShulrdLrhy/Khy//8Psvf/3Vl7/51e++/uq+tH/89OePnz786YvyD+/Hmy3+WMV4j154u14sSistSi+8o5W+yrAyehnrxbu3F+/e6vnEVkurfLgyavFaZi2rll1L1GKVX/y9MWBMGCPGjDFkTBljFnr9yy+tvvra+FhT/zhf... |
703,672 | GCD of two numbers | Given two positive integers a and b, find GCD of a and b.
Examples:
Input:
a = 3
b = 6
Output:
3
Explanation:
GCD of 3 and 6 is 3
Input:
a = 1
b = 1
Output:
1
Explanation:
GCD of 1 and 1 is 1
Constraints:
1 ≤ a, b ≤ 10**9 | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1708867817,
"func_sign": [
"public static int gcd(int a, int b)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(ne... | {
"class_name": "Solution",
"created_at_timestamp": 1708867817,
"func_sign": [
"gcd(self, a : int, b : int) -> int"
],
"initial_code": "if __name__ == \"__main__\":\n t = int(input())\n for _ in range(t):\n a = int(input())\n b = int(input())\n obj = Solution()\n res = ob... | eJxrYJn6j5UBDCK+AxnR1UqZeQWlJUpWCkqGMXmGBjAQk2cJA0o6CkqpFQWpySWpKfH5pSUI5XUxeUq1OgqoZlhaGJmYGpqZGsfkmZpbWACZhiSaYGhkbGJqZm5hCTLM3MzUxNgIlxGWuBwBAcbmSExcRiCUYncNEJHqAaRgJFkvsnZSgx7hFTKsJRRQRPmWoNORFONLPmhOgqUlCgMIyUgQEy3IkGQw0zBIAckhA07IUDcTlZ6JzVQmpGcqtJCDs0EUyckFEUvIAUhxnkcElQn5YYXTpxR5FTnoKc/iWFIh4TiiWjqNnaIHAIWtv2w= |
713,541 | Last cell in a Matrix | Given a binary matrixof dimensionswith Rrows and Ccolumns. Start fromcell(0, 0), moving in theright direction. Perform the following operations:
Examples:
Input:
matrix[][] = {{0,1},
{1,0}}
R=2
C=2
Output:
(1,1)
Explanation:
Input:
matrix[][] = {{0, 1, 1, 1, 0},
{1, 0, 1, 0, 1},
{1, 1, 1, 0, 0}}
R=3
C=5... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1673867042,
"func_sign": [
"static int [] endPoints(int [][]matrix, int R, int C)"
],
"initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])throws IOException\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1673867042,
"func_sign": [
"endPoints(self, matrix, R, C)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n r, c = map(int, input().strip().split())\n matrix =... | eJzNVM0KwjAM9iDevPkAoSeFIU3cLj6J4MSD7uCl7rCBIIoPoe9r1x/ZcC1dvbjCknbJ1+RLlsf4NZuM1LOZSmV7ZSdR1hVbA8NcIMgXZwmw4lIWh6o47s91Zb7PeQJ8kYt7LtgtgR5PjPEkIOsOTgD0AKxgJYMGubrCEwx5sVB6NzwANlhq58IiT1wppAbEJKfxWidKjeEsg8wi4iff9j3O05hEyBJsgnaCoJdZUrkrCKXFhILSz3CImkcjTaG45tTKPkv8Q8vBVHD3zxbaLU1NQjqGPBMhrGt+aZtu72Ekihov1GQcM6RcV37XJNwS... |
700,373 | You and your books | You have n stacks of books. Each stack of books has some height arr[i] equal to the number of books on that stack ( considering all the books are identical and each book has a height of 1 unit ). In one move, you can select any number of consecutive stacks of books such that the height of each selected stack of books a... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1618519841,
"func_sign": [
"long max_Books(int arr[], int n, int k)"
],
"initial_code": "import java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws Exception {\n Scanner sc = new Scanner(System.in);\n int T = sc.n... | {
"class_name": "Solution",
"created_at_timestamp": 1618519841,
"func_sign": [
"max_Books(self, n, k, arr)"
],
"initial_code": "if __name__ == '__main__':\n t = int(input())\n for i in range(t):\n temp = list(map(int, input().strip().split()))\n n = temp[0]\n k = temp[1]\n ... | eJzFVs1OwzAM5sCFt7B6npDjNGnLkyARxAF24BJ26KRJEwjxDPC+JE6WbqwWU1XYLHXOT798sT+neb/8+ri64N/tNjh32+rZr9Z9dQOVcl4hGOctNNCCAQ0ECurg2WoB1XKzWj72y6eHl3WfXyF0/s356nUBP4AM1M5jeJ0CTM2W4BByrwCpJUhC0M5r0BkoQlGB1AxKvJyWwRuJL4F13sStQno27Nn4lMBIYmogDFFhmZhhbmHmmUZTD/dJMW7HlkFh9jEbHRbGuLeQXBX3phIjxZlA6EKu42YVt3bTihv/qTQNSAsr1EI4ahbVoIUU... |
703,522 | Divisible by 7 | Given an n-digit large number in form of string, check whether it is divisible by 7 or not.Print 1if divisible by 7, otherwise 0.
Examples:
Input:
num = "8955795758
"
Output:
1
Explanation:
8955795758 is divisible
by 7.
Input:
num = "1000"
Output:
0
Explanation:
1000 is not divisible
by 7.
Constraints:
1 ≤ |num| ≤... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int isdivisible7(String num)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass GFG {\n public static void main(Strin... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"isdivisible7(self, num)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n s = input().strip()\n ob = Solution()\n print(ob.i... | eJxrYJlayMIABhFZQEZ0tVJmXkFpiZKVgpJhTJ55TJ6SjoJSakVBanJJakp8fmkJQrIOKFmro4Cqw9CEdC1GxiamZji1GeDQZgkGJNtmZEi6FguStZiQ7jAzY5K1GKAA0rWTaSFSnBG0G1fsgQwgWQ+exIVXj6EJNGWSrB3hYSCOiQGlBEp9TlmcAcMNmrzIyTMmlrhTP1Y9+JyI03HEuCx2ih4A2xZi9A== |
704,500 | Minimum Cost To Make Two Strings Identical | Given two strings x and y, and two values costX and costY, the task is to find the minimum cost required to make the given two strings identical. You can delete characters from both the strings. The cost of deleting a character from string X is costX and from Y is costY. The cost of removing all characters from a strin... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int findMinCost(String x, String y, int costX, int costY)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GfG {\n public static void main(String args[]) {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"findMinCost(self, x, y, costX, costY)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n\n for i in range(T):\n X, Y, costX, costY = input().split()\n co... | eJy1VduO2jAQ7UMf+hmjPK8qOxcI/ZKVSlUFZ3LZje1gOxCoWvUj2u/oW7+viaGCsthQdneQAHmSOTPHZ2a+v/35+90ba/e/hj8fvwS1aDsTfICAzkW2YDkWZVU/PDZcyHaptOlW636z3W769aozWi1bKXjz+FBXZYE5W2RAwyhOJtN0RoCSwWA2WnAHAfYtMoP5Z9mZvyAJHZxkLr7NRfD1Dk7wTwyeHCQWweIQB4QreC93H9j/9hDZYJEn1mT0OeI1UpTaqFqU69pUOuPYoChNRcHlCXdcQRJHIXUhjuZAzOuiQIXCsCpT2fCi0hTO... |
703,755 | Check an Integer is power of 3 or not | Given a positive integer N, write a function to find if it is a power of three or not.
Examples:
Input:
N = 3
Output:
Yes
Explanation:
3
**1
is a power of 3.
Input:
N = 5
Output:
No
Explanation:
5 is not a power of 3.
| geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static String isPowerof3(int N)"
],
"initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])throws IOException\n {\n BufferedRea... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"isPowerof3(ob,N)"
],
"initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n\n ob = Solution()\n print(ob.isPowerof3(... | eJxrYJkax8IABhHhQEZ0tVJmXkFpiZKVgpJhTJ6lko6CUmpFQWpySWpKfH5pCVQqMrU4Jq8uJk+pVkcBVYeROclaLAxJt8XEmGQ95kZk+MbQgnT/mJmake4jQ0szC9L9ZGppYEK6rwzNzQ1NSPeXkTmeFOGXjyt2cVmERwfJWiAI4kByQh8UZZAkgksvPqtBqcSCnFQMshPkXdLDCIxiDMFejiEnuaGFGdD/eKMXT7YiIrpip+gBAJ+YZaQ= |
713,975 | Avoid Explosion | Geek is a chemical scientist who is performing an experiment to find an antidote to a poison. The experiment involves mixing some solutions in a flask. Based on the theoretical research Geek has done, he came up with an n*2 array 'mix', where mix[i] = {X, Y} denotes solutions X and Y that needs to be mixed.
Also, from ... | geeksforgeeks | Hard | {
"class_name": "Solution",
"created_at_timestamp": 1675772636,
"func_sign": [
"ArrayList<String> avoidExlosion(int mix[][], int n, int danger[][], int m)"
],
"initial_code": "// Initial Template for Java\n\nimport java.util.*;\nimport java.io.*;\n\n public class GFG {\n public static void main(String... | {
"class_name": "Solution",
"created_at_timestamp": 1675772636,
"func_sign": [
"avoidExlosion(self, mix, n, danger, m)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n for _ in range(int(input())):\n n, m = map(int, input().split())\n mix = [[0 for _ ... | eJztVsuO00AQ5MAX8AUtn1fI3eMZj/kIroAwcIAcuHhX2qyEhEB8BPwvU9VZSBCOnddqI2WlSMl6prqqpro9P57+ev/sCf9evypf3n6tPg83d8vqhVTaD600/aBi/WAS+iHgZyOxH6KkfkjSYoliSYMlEUsSlpQH1ZVUiy83i4/LxacP13fLFeqbxa3g8/JaNr/2w/ey6duVbFJIKLyFAqsHPG3wP9taeK2o/xwpqjUqTAnP/ZCl64dOtOYeconYk7CnxZ7M55N2/IfdNEvW2Z0ltqqoEYGcExBaIGQgdEDgap0wdAb9rRLybJ//OecW... |
706,104 | Jump Game | Given an positive integer N and a list of N integers A[]. Each element in the array denotes the maximum length of jump you can cover. Find out if you can make it to the last index if you start at the first index of the list.
Examples:
Input:
N =
6
A[] =
{1, 2, 0, 3, 0, 0}
Output:
1
Explanation:
Jump 1 step from fir... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int canReach(int[] A, int N)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader read =\n new BufferedRea... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"canReach(self, A, N)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n A = list(map(int, input().split()))\n\n ... | eJytVDsOwjAMZYB7RJkr5CTtwkmQCGKADiyhQyshIRCHgCuwcUecNKVQYcCFRpYy2O9j1zkOz9fRIHzTC15mO7l2RVXKiZDKOgXWGQFCY6QY9VEyETLfFvmyzFeLTVXGAkw+WCf3ieigZBiIYZr6cE9F1hNPg1eGMA0ckIcNjVJ1NPxtUByK4DChqXVb1V199qC6bbV5cuPzgeOISu6kkaAvZmkdlUz51X76PYp6TC8w8bkEmwyA3g7WhOqWRgUBkCneV3P9vtmfnxYICPD/oP++OrzdYZtpf0D2CxmtaWu1c58elPlpfANQQI0p |
701,966 | Print Anagrams Together | Given an array of strings, return all groups of strings that are anagrams. The groups must be created in order of their appearance in the original array. Look at the sample case for clarification.
Examples:
Input:
N = 5
words[] = {act,god,cat,dog,tac}
Output:
act cat tac
god dog
Explanation:
There are 2 groups of
a... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1730726713,
"func_sign": [
"public ArrayList<ArrayList<String>> anagrams(String[] arr)"
],
"initial_code": "import java.util.*;\n\n//Position this line where user code will be pasted.\n\npublic class Main {\n public static void main(String[] args) {\n... | {
"class_name": "Solution",
"created_at_timestamp": 1729589971,
"func_sign": [
"Anagrams(self, words, n)"
],
"initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n t = int(input())\n for tcs in range(t):\n words = input().split()\n\n ob = Solution()\n ans... | eJzNV2uO00AM5gcX4AZW+YdWSPuXkyAxCE1ek1c9aR5tEgTiEHBf7EnaZJKdqNsuaCM1mThj+7PHr/56++fDuzfm+vyeFl++7xIsmnr3CXaPAiVd4NEFPl0Q0AXS8wMIfI8++IEEScvdA+zCtgj9Ogy+6aYeBRhuErJmIKqRKtDIFWgkC/wpcPfjAWwQbde1QL92pnqPuoBC4x7aru876Lu+daG4MAmc2OZiec1CBLIYFwyWE0YqTtIsZzmHsqqb48mwtqdjU1flgUXnWZrEKgqNysMpLOuuSXShk6ary/B0AFkFJIakZCntCyoJfesf... |
703,220 | Longest Palindrome in a String | Given a string str, find the longest palindromic substring in str. Substring of string str: str[ i . . . . j ] where 0 ≤ i ≤ j < len(str). Return the longest palindromic substring of str.
Examples:
Input:
str = "aaaabbaa"
Output:
aabbaa
Explanation:
The longest Palindromic substring is "aabbaa".
Input:
str = "abc"
O... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1731263624,
"func_sign": [
"static String longestPalindrome(String s)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n Buf... | {
"class_name": "Solution",
"created_at_timestamp": 1731263624,
"func_sign": [
"longestPalindrome(self, s: str) -> str"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n\n for _ in range(t):\n S = input()\n\n ob = Solution()\n\n ... | eJzlVc1OhDAQ9uDJp9hw3pioN5/ERIwZygBdoIVS/jQmPoQ+kDcfy9LFXRYpCu5uTOyGbCkz30y/6dd5Pn19PzvR4+ZNTW4fLcqSXFrXC+vKZuA4AIS4rn4A1itETdd/jl4hLjZTa7mwsEqQSHTveS5bmE/vHd+Om82sp+ViN25VP9SVtvB8r7VinDMBBAkImxFaUBKDC3G7ZAjew9j4bya92Jc287jwEcMsCxF99WIzB5j6GSJsbW2m7b5gXugPBY9oTCNemKF6VkPJgSKvYRPR83w/CGwWYYGRZqIhyIQMreFgcscYzoxxjLyMhB1+... |
705,830 | Nth digit of pi | Calculate the Nth digit in the representation of Pi.
Examples:
Input:
N =
1
Output:
3
Explanation:
Value of Pi is 3.14...
So, the first digit is 3.
Input:
N =
2
Output:
1
Explanation:
Value of Pi is 3.14...
So, the second digit is 1.
Constraints:
1 <= N <= 10**4 | geeksforgeeks | Hard | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int nthDigOfPi(int N)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader re... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"nthDigOfPi(self, N)"
],
"initial_code": "# Initial Template for Python 3\nimport math\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n\n ob = Solution()\n pr... | eJytk00OgjAQhVngPUjXxJSWgnoSE2tcKAs3lQUkJkbjIfSw7uwPKmBnkMRZsGm+N2/eMNfwHkwCW8tHGASrE9mrsq7IIiKJVAmllMQRKY5lsa2K3eZQV83rTKqLVOQcR11EwAgDENMFYnIfwzXjMKmY/XJYgVsFZ5f61LStRBiRXIAioiXyPcBcFwBmUEeKRuVMewPTT+xtFw+PtVx7gzQpMp6iQ/eQVAvmmX5KOTO4LjQAF7lozeONxDpplgoa8s7QWt/45X1g/z+FS3onGdgJZIAN2OfgvTX9kJ4Jxkpp5x6D9lKTzdn/I73OGn68... |
703,440 | Subarray Inversions | Given an array arr[], the task is to find the sum of the number of inversions in all subarrays of length k. To clarify, determine the number of inversions in each of the n-k+1 (where, n is the size of the array)subarrays of length k and add them together.
Examples:
Input:
arr[] = [1, 6, 7, 2], k = 3
Output:
2
Explana... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public long inversion_count(int[] a, int k)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass Abc {\n public static void main(String args[]) throws IOException {\n BufferedReader in = new BufferedR... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"inversion_count(self, arr, k)"
],
"initial_code": "if __name__ == '__main__':\n t = int(input())\n for _ in range(0, t):\n a = list(map(int, input().split()))\n k = int(input())\n ob = Solution()\n ... | eJy1VUFu3DAM7KGHPoPweRGIFCVReUmAuuih3UMuzh42QIEiQR7RPiG3PrIjGRsgBzp2drPA0DZWpkYzJP30+e+/L5/67+YZN19/D7fT4f44XNPA48QhkAAR4IR7IAKKZ8U1hYZxSuM07GjY/zrsfxz3P7/f3R9PSWScHvHvw45ep661Uq0GFCADCVAgAgIwEBoHN7kmJ7lSJKFETIWMkJxaluizDE4ixotNA2p0YyesnXLqpGfapRO3mXojP07Z3apmb6uAlw3JMpLPB2Ba1LZ4rJst3M2RHmOPOtvVY+6x9Gg91h55WXBWVyiJqIhM... |
706,303 | Find all Critical Connections in the Graph | A critical connection refers to an edge that, upon removal, will make it impossible for certain nodes to reach each other through any path. You are given an undirected connected graph with v vertices and e edges and each vertex distinct and ranges from 0 to v-1, and you have to find all critical connections in the grap... | geeksforgeeks | Hard | {
"class_name": "Solution",
"created_at_timestamp": 1616310748,
"func_sign": [
"public ArrayList<ArrayList<Integer>> criticalConnections(int v, ArrayList<ArrayList<Integer>> adj)"
],
"initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG\n{\n... | {
"class_name": "Solution",
"created_at_timestamp": 1616310748,
"func_sign": [
"criticalConnections(self, v, adj)"
],
"initial_code": "# Initial Template for Python 3\n\nimport sys\nsys.setrecursionlimit(10**6)\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n V, E = map... | eJy9VbFOwzAQZWBhZmM6ea5Qzo7thC9BwogBMrCYDqlUCSHxEfC/9F1MRaU2jVOXDKfEl3vP9+45+bz8vrm6kOv+enPz8K5e43LVqztSHKIlF2JFjKBD5CGYEA3VIWoEtSDVrZfdc9+9PL2t+lSsPha0i+XIJyyB0VuYmizWLLI2A7ChdgRQti6cniokcqB5A2v/dl4BnIemLdAcaDxoGtC0oGnSnjyCNKTxnsmSCdR6V/SDff0SSusyDYvHA1xSPt7rMSGbreptmhYjq5E1yNYj/HuoNXGdSd0SV8OmRSCWUtEA61ky85yuGY+Tabzs... |
701,275 | Distance of nearest cell having 1 | Given a binary grid of n*m. Find the distance of the nearest 1 in the gridfor each cell.The distance is calculated as|i1 - i2| + |j1- j2|, where i1, j1are the row number and column number of the current cell, and i2, j2are the row number and column number of the nearest cell having value 1.There should be atleast one 1... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int[][] nearest(int[][] grid)"
],
"initial_code": "import java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG\n{\n public static void main(String[] args) throws IOException\n {\n BufferedReader ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"nearest(self, grid)"
],
"initial_code": "if __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n, m = map(int, input().split())\n grid = []\n for _ in range(n):\n a = list(m... | eJztV81OwzAM5sAD8AhWzxOK1x9WngSJIg6wA5eywyYhISQeAi7ceFPiOF2dv6bSLhtae3G/fk1s57OTfl5+/15dmOvuRxv378VLv9lti1soVLGAYv22WT9t18+Pr7utxYuPBQgadn0Nddcr4BsHE0GxifRIJjKl660BqSkqKGFp6F0/WKjtwVoCj0FWCTw0WZW2Q/caaMSUo4PCReGkcHNvOj4nvWYvBr9Hmz2Xvo926URSObHU0WhQE9QYgorFFYlPQD4o4vUgCYr4nZy5oAN5OYzmMpPTFlZwA43OhdREiFGOQ4xyHWKU8xCj3IdY... |
703,459 | First and Last Occurrences | Given a sorted array arr containing n elements with possibly some duplicate, the task is to find the first and last occurrences of an element x in the given array.Note:If the numberx is not found in the array then return both the indices as -1.
Examples:
Input:
n=9, x=5
arr[] = { 1, 3, 5, 5, 5, 5, 67, 123, 125 }
Outpu... | geeksforgeeks | Medium | {
"class_name": "GFG",
"created_at_timestamp": 1729172286,
"func_sign": [
"ArrayList<Integer> find(int arr[], int x)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\n// Driver class\nclass Array {\n\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1729172286,
"func_sign": [
"find(self, arr, x)"
],
"initial_code": "t = int(input()) # Number of test cases\nfor _ in range(t):\n arr = list(map(int, input().split())) # Input array for each test case\n x = int(input()) # Element to search for\n... | eJy1VstOw0AM5MCFvxjlXCF7d/PiS5AI4gA9cAkVaqUihMRHwP8ymwJKIN6mKdRdqVId22PPePN6+v50dtJ9Lh/54+o5u29Xm3V2gUybVuHgEZAnrUCJCjVUoAp1UA8N0BxaQEtoBa3hpGnzbIFsuV0tb9fLu5uHzfozFZ2rpm3a7GWBYQUOKfOGhV82qLhpvVEIa3bFeCVE5wS+9w2CXFAISkElqAlfYgt46Km+d+iq9FU6K72V7lrHgDwxMP2d7x36u5wN82IU6iKK0TJxnDmGMHIStFq9idj5uHD4wukLJyp54pAYQmYIqSF17FkM... |
703,751 | Gray Code | You are given a decimal number n. You need to find the gray code of the number n and convertit into decimal.
Examples:
Input:
n =
7
Output:
4
Explanation:
7 is represented as 111 in binary form.
The gray code of 111 is 100, in the binary
form whose decimal equivalent is 4.
Input:
n =
10
Output:
15
Explanation:
10... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int getGray(int n)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader read =\n new BufferedReader(new In... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"getGray(self, n)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n n = int(input())\n\n ob = Solution()\n print(ob.getGray(n... | eJydk8EKAiEURVvMhwyuh8inI0NfEmS0KBdtbBYKQVP0EfW/OVpB0LXMjeLj4L33PS/VbagmcS18OCyPbGd779i8ZlzbmbasqZk59GbjzHa99+5RDJVzKJ6a+p3gkOCAIEgIQAhIECAkJBQgOuwDPcJbyHQIUdiKRO4zESM3AocskTaRuklpK3+TUoq4u2ggUr+K54irXJjtd5da/+VzzDbfykzE/Gn2NxGk4PSF+zHu4r8U1ev016OJz7qiMF1skLCiF7S6Tu+SzXFS |
703,433 | Sort the pile of cards | Given a shuffled array arr[] where each element represents a card numbered from 1 to n, your task is to determine the minimum number of operations required to sort the array in increasing order. In each operation, called moveCard(x), you can move the card with value x (where 1 ≤ x ≤ n) to the top of the array, without ... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int minOps(int arr[])"
],
"initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass GFG {\n public sta... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"minOps(self, arr)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input())\n\n while t > 0:\n arr = list(map(int, input().split()))\n ob = Solution()\n ... | eJzt3M2KZVlexmEHXsghx43E+n+u8CocCrY40Bo4KXtQDQ2ieBF6j868BZ9oxS+Itoui6a6snbAhk/ydE5n5nDg731hk/tMf/8u//dkf/frbn/+r7/zF33/5229/8cvvvvzp68v5+bf7ile/6pWvefnhl5+9vnzzq19889ffffM3f/V3v/zuP8P5+bf/6Cf/4Wev//3o8/Z6f93XevB/PEn8hid5/+xJ+nXqdfJ1PPq8vtdznvrkSf+/B+Ynj/ttPmh/+qfx5tf+/u66rnWNq13lSle4jkt3dVd3dVd3dVd3dVd3dVe3utWtbnWrW93q... |
702,990 | Odd to Even | Given an odd number in the form of string, the task is to make largest even number possible from the given number provided one is allowed to do exactly only one swap operation, if no such number is possible then return the input string itself.
Examples:
Input:
s = 4543
Output:
4534
Explanation:
Swap 4(3rd pos) and 3.... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public String makeEven(String s)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GfG\n{\n public static void main(String args[])\n {\n Scanner sc = new Scanner(System.in);\n int t = sc.nextIn... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"makeEven(self, s)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n\n for tcs in range(T):\n Str = input()\n ob = Solution()\n print(ob.makeEven(... | eJyNVLEOgjAQddDJzS8gnYnh2tIWv8REjIMyuFQGSEyMxo/Q/xVKITg86E0k797x7t1d38vvZrVwsV83H4cHu9qyrtguYpTbzGiVSkEsjlhxL4tzVVxOt7ryGQ4mIXP7yi17xtE/m0tlSKQ6Q3SPc8B33LYI4DvcSAX5CRcyVdogAZT5hARU6NrnlIACA44KCEAUyLImAKWFUKdZL2RqUM0cEV/7APQeRj7P2tzh6O8C9ixwyzpQMxLdWTLjGDTMtzwxYZdBWk0MOgnYsDaP0HY5kXP3OXGgerw6jVUWu0mwj5BD43jzaGzCIMdpmX+A... |
703,776 | if-else (Decision Making) | Given two integers, nand m. The task is to check the relation between n and m.
Examples:
Input:
n = 4, m = 8
Output:
lesser
Explanation:
4 < 8 so print '
lesser
'.
Input:
n = 8, m = 8
Output:
equal
Explanation:
8 = 8 so print '
equal
'.
Constraints:
-10**9
<= m , n <= 10**9 | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1708935411,
"func_sign": [
"public static String compareNM(int n, int m)"
],
"initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n Buf... | {
"class_name": "Solution",
"created_at_timestamp": 1708935411,
"func_sign": [
"compareNM(self, n : int, m : int) -> str"
],
"initial_code": "if __name__ == \"__main__\":\n t = int(input())\n for _ in range(t):\n n = int(input())\n m = int(input())\n obj = Solution()\n re... | eJxrYJm6hI0BDCLmAhnR1UqZeQWlJUpWCkqGMXmGBjAQk6eL4CjpKCilVhSkJpekpsTnl5ZANaQXpSaWpBbF5NXF5CnV6iigmqWLbBhBs3JSi4txG2UJA8hsHCalFpYm5uAwiCQn4TMIxXMEnYTXc8gmETIIf4gDDSDHL8iBS3GcgzDF4Un1qCEnXrAGC1mhYmmJM5ThTEuyMoYl2GhIqEMMpo0DifYE2T7BEmvQFE1G7BGZwUkPCEsc6YsyL+O0GHcpiiXgKQ82FDdZ4g0NNMsJRCB5boudogcAkwDypQ== |
709,857 | Maximum number of events that can be attended | There are N events inGeek's city. You are given two arrays start[] and end[] denoting starting and ending day of the events respectively. Event i starts at start[i] and ends at end[i].
You can attend an event i at any day d between start[i] and end[i] (start[i] ≤ d ≤ end[i]). But you can attend only one event in a day.... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1644383491,
"func_sign": [
"static int maxEvents(int[] start, int[] end, int N)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader read =\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1644383491,
"func_sign": [
"maxEvents(self, start, end, N)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n start = list(map(int, input().s... | eJztl09uJkUMxVlwAk5gZT1CtstdfzgJEkEsIAs2YRYZCQmBOATcix3X4T2XiYiSDpNMiFjMfJH6m1Z/7ld+/rlcv376+5+ffZL/vvwDX7766eL767fvbi6+kAu7vD4ur01cGj742iTkkC7j4o1cXP349urbm6vvvvnh3U39AI/8cnl98fMbuRtl7CiBn04xFfPLa0ekIUvMxJpYnIQcJyFNIU6OlNMz7mIw3B34PvP/fNPtnz/1Bbn0dlflITbEljiW08QP8SG+uJh/rA2LEetiU1zFXTzEu/iUpica7Cxxrlwp4+DVeF1TaYeESmDl... |
705,157 | Surround the 1's | Given a matrix of order nxm, composed of only 0's and 1's, find the number of 1's in the matrix that are surrounded by an even number (>0) of 0's. The surrounding of a cell in the matrix is defined as the elements above, below, on left, on right as well as the 4 diagonal elements around the cell of the matrix. Hence, t... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int Count(int[][] matrix)"
],
"initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG\n{\n public static void main(String[] args) throws IOException\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"Count(self, matrix)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n, m = input().split()\n n = int(n)\n m = int(m)\n ... | eJzNVDuOwjAQpVhxjpFrhDz5KctJkDaIYklBEyiChIQWcQi42nZ7l40/JCbhOfwKMlLi2J434+c3c/g4/Q0H+pn+VoOvnVgW600pJiQ4K5iqlxQjEvl2nX+X+WK+2pR2XWbFPivEz4gunQIKlGe1LImBbwB8Qwp1VNLBpfkwhEEpRBSp6Np0GsStgbY7UWOKbVYmMztQgD2zINCnjwUn+XPGAIYBTEKJpY8cSo2d+SUGP8622kD8FMRnShss9lKOjsCVo0skOex2pppzvPtOwEIY+fXMRhJt5HrmnmKTuLBRSSe9ZY0qBwn6xm4B1dER... |
703,269 | Count subsets having distinct even numbers | Given an array arr of integers, you need to count all unique subsets that contain only even numbers from the array. Two subsets are considered identical if they contain the same set of elements, regardless of their order.
Examples:
Input:
arr[] = [4, 2, 1, 9, 2, 6, 5, 3]
Output:
7
Explanation:
The subsets are: [4], ... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public long countSubsets(int[] arr)"
],
"initial_code": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int t = Integer.pars... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"countSubsets(self, arr)"
],
"initial_code": "def main():\n T = int(input()) # Read the number of test cases\n while T > 0:\n # Convert input to list of integers\n a = list(map(int, input().strip().split())... | eJy1lMFKA0EMhj2Iz/Gz5yKZZLIz65MIVjxoD15qDy0URPEh9ObNFzUZldZKlC12IMMuy+RL8v87T8cvbydHbZ2/2sPFfXc7X6yW3Rm6NJ0nsoW99m6CbrZezK6Xs5uru9Vyk/RxOu8eJtghQaAoGIJzFJ1rvGTBFmKRLdSitygW1SLKKlE5o8snMEEImaCEnlAIlTC0aUTJiCXIx8jo4aUjWWPWk7VTncEMzuAeXJ0nDMmQHlKNHYJy1aLh6C2H8dSIxZhDo6YGlsbWhi9eQRqsiPH9pE9fuEhNoSZP0yY1Af2Do8hJ5CAKOUy5BBx1... |
704,857 | Kill Captain America | Captain America is hiding from Thanos in a maze full of N rooms connected by M gates.
The maze is designed in such a way that each room leads to another room via gates. All connecting gates are unidirectional.Captain America is hiding only in those rooms which are accessible directly/indirectly through every other room... | geeksforgeeks | Hard | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int captainAmerica(int N, int M, int V[][])"
],
"initial_code": "//Initial Template for Java\n\n//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])t... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"captainAmerica(self, N, M, V)"
],
"initial_code": "# Initial Template for Python 3\n\n\nif __name__ == '__main__':\n ob = Solution()\n t = int(input())\n for _ in range(t):\n N, M = map(int, input().split())\n ... | eJytk00OgjAQhV3oPSZdE0NL+fMYrjSOcaEs3FQWkJgYjYfQ+0prwQAptCqrJu18b96b4T59rmcT9a2W1WFzIUeRlwVZAKEoKPgoiAckO+fZvsgOu1NZfK5v1eXVg3YNH6jxjTWBFGMomDwFQJ0REcQ9BIcQRQiRvOVaxYANDFjqQzrGjSFBkch3KVB380zCtYLZNzP67kTHv4ju5/QDe4QpaRVqxwgHtYTmsfGhJXQ1QaE/Ddf9hzYGUYOwacoZqQsl6B+GqjDdGhjWtttI+o5SenHxoKRR/l22+nUFjjdiD61H0KTJmjjHdmz7mL8A... |
704,969 | Triangular Number | Given a number N.Check whether it is a triangular number or not.Note:A number is termed as a triangular number if we can represent it in the form of a triangular grid of points such that the points form an equilateral triangle and each row contains as many points as the row number, i.e., the first row has one point, th... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int isTriangular(int N)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader read =\... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"isTriangular(self, N)"
],
"initial_code": "# Initial Template for Python 3\n\nimport math\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n ob = Solution()\n ... | eJxrYJlax8IABhHlQEZ0tVJmXkFpiZKVgpJhTJ5ZTJ6SjoJSakVBanJJakp8fmkJQrIOKFmro4Cqw9CAdC2mJGsxMiRdiwXJWoxJ974J6X4xI90Wc9L9Ykl6iIG0ABHJ0YnHQwa4wsCQdD2goIYkhRhISiU54A3NYM4l3cFguyl2gqEhifYCXUtW6BricK+hGRl+NyTCTDNoygYlIII2xE7RAwBoFnCQ |
703,498 | Smallest number repeating K times | Given an array arr, the goal is to find out the smallest number that is repeated exactly ‘k’ times.Note:If there is no such element then return-1.
Examples:
Input:
arr[] = [2, 2, 1, 3, 1], k = 2
Output:
1
Explanation:
Here in array, 2 is repeated 2 times, 1 is repeated 2 times, 3 is repeated 1 time. Hence 2 and 1 bot... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int findDuplicate(int[] arr, int k)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass Main {\n public static void main(String args[]) throws IOException {\n BufferedReader read = new Buffere... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"findDuplicate(self, arr, k)"
],
"initial_code": "if __name__ == '__main__':\n tc = int(input().strip())\n while tc > 0:\n arr = list(map(int, input().strip().split()))\n k = int(input().strip())\n ob... | eJzNVMFOwzAMrRCC33jKeUxz0qTtvgSJoh1YD1zKDp2EhCbtI7av5ULiVp2AuTRjaCTRO8S1/Z4dd3u9v7pNeN2/3yTJw5t6rlfrRs2hqKzDUROo6nVVPTXVcvGybg5WtZngy/czvwZ8WvMRP3jQ0ZnQBRQ95XwaBiksHDLkKHykaKmQTzCLnIQCIJDSTMwwuZQJWibpd1mbKH74+/29iCB/r0EGlIIsyIEyUA4qoL1yK5blhyaj8KuHvIesB8cgP4bWOi5J/jmqDZAGMAF0AApw0tvz92z8D8pmF5BG59Dm4kZYx44wB7PiFN8N/v4k... |
701,742 | Check Equal Arrays | Given two arrays arr1 and arr2 of equal size, the task is to find whether the given arrays are equal. Two arrays are said to be equal if both contain the same set of elements, arrangements (or permutations) of elements may be different though.Note: If there are repetitions, then counts of repeated elements must also be... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1616488754,
"func_sign": [
"public static boolean check(int[] arr1, int[] arr2)"
],
"initial_code": "// Initial Template for Java\n\n/*package whatever //do not write package name here */\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\n... | {
"class_name": "Solution",
"created_at_timestamp": 1616488754,
"func_sign": [
"check(self, arr1, arr2) -> bool"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for tc in range(t):\n arr1 = [int(x) for x in input().replace(' ', ' ').stri... | eJzdVs1q3DAQ7qHnPsOHz6Fo9K+8Q285FLqllHYLheCGZBcKodCHaN+3I1mW7UYb7PVuSSMzZizNr/XNSD9f/r569SKNt2+YeXfffG1v9rvmEo3ctCQEJJNi0kyGyTI5Js8UmFhGJMnu0+dlm8V1Vped6KYN/QBBQkHDwMLBg2eipcosilJzgWb7/Wb7abf9/OHbfpdj3d3ut5u2ezc/LjBKgzatwqxntuCjQTx0HzgLx9kYzkpxdgROUzxMf6FZkkob63xA8M4arSSB+gHZD6h+cCSDYFEeVIrgoLwkpIgXHP2sVY4IY6Ax3hh2jD4G... |
702,810 | Find pairs with given relation | Given an array arr[] of distinct integers, write a program to determine if there are two distinct pairs of elements (a, b) and (c, d) in the array such that the product of the first pair a * b is equal to the product of the second pair c * d. All four elements a, b, c, and d are distinct. If such pairs exist, return 1,... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public static int findPairs(int arr[])"
],
"initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass GFG {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"findPairs(self,arr)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input())\n while t > 0:\n arr = list(map(int, input().split()))\n ob = Solution()\n ... | eJy1UztOxDAUpIB7jFwvaF6cxDYnQWIRBaSgCVtkJaQViEPAfXl2vLAgJeAALhIXnt/7PB+/7k6O0rkY9HK5M3f9ZjuYcxhZ94IKFrVZwXQPm+5m6G6v77dDfnCqL57WvXlc4SssAqsJ2BQqSjVwxWJERViiJhqiJRzhiUAIWeghB1YfLRw8gnJANE8FsZAa0kBaiIN4SFDlYgE1ReZv0FNcpWbEJ4pCcNTT3ow/luMPy3OQo5QlwSBLEkhu8seU/aTdM5M6BhL/y0jRS3kUO1uDGdd/ZTvtTkLaT47Ktumb3YyE+xplHV2j/1IaFcST... |
702,881 | Fascinating Number | Given a number n. Your task is to check whether it is fascinating or not.
Examples:
Input:
n = 192
Output:
true
Explanation:
After multiplication with 2 and 3, and concatenating with original number, number will become 192384576 which contains all digits from 1 to 9.
Input:
n = 853
Output:
false
Explanation:
It is ... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615306351,
"func_sign": [
"boolean fascinating(long n)"
],
"initial_code": "import java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass GFG {\n public static void main(String args[]) {\n Scanner sc = new Scanner(System... | {
"class_name": "Solution",
"created_at_timestamp": 1615306351,
"func_sign": [
"fascinating(self,n)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n n = int(input().strip())\n ob = Solution()\n ans = ob.fasc... | eJxrYJl6nYUBDCIuABnR1UqZeQWlJUpWCkqGMXmGBgZKOgpKqRUFqcklqSnx+aUlUMm0xJzi1Ji8upg8pVodBVRdlpaWZOgyNDImR5elBRm6jAxxubCkqBSnJnMzMqwyNjIn3SpjE1MyrDI3NiJDl4Uhmd6CuNMwJoacNGJkCNFOTkqB6Y2JgUQleWaA0imQQLjEEmeiwJvYIYFBliPgeuFsSDKDiJCX3gzIzLNogYotmC1xhhtZ+R2SiMjK9QaGxPkydooeABrxjYc= |
701,207 | Rearrange an array with O(1) extra space | Given an arrayarr[]of size N where every element is in the range from0ton-1. Rearrange the given array so that the transformed array arr**T[i] becomesarr[arr[i]].
Examples:
Input:
N = 2
arr[] = {1,0}
Output:
0 1
Explanation:
arr[arr[0]] = arr[1] = 0
arr[arr[1]] = arr[0] = 1
So, arr
**T
becomes {0, 1}
Input:
N = 5
... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static void arrange(long arr[], int n)"
],
"initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.io.*;\nimport java.lang.*;\n\nclass Main\n{\n public static void main(String args[])throws IOExcept... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"arrange(self,arr, n)"
],
"initial_code": "# Initial Template for Python 3\nimport math\n\n\ndef main():\n T = int(input())\n while T > 0:\n n = int(input())\n arr = [int(x) for x in input().strip().split()]... | eJy1VjFOw0AQpKDhFyPXEfKufWeblyBxiAJS0BwpEikSAvEI+Acd32P34sKJfYePJHFjrce7M3O763xcfv1cXYTf7bfc3L0Wz361WRc3KCrnqXS+Q4sGFgY1KjAIEiTjfCm3LKFaHlmBtOhAEiSQoCpQ7TwrVsItqAFZkJFweMgBWGIifbFAsdyulo/r5dPDy2bd85mq5/z7HCKzccrPBq7CuE9fvC0wsIV2tmgi4TrkH+GtKFU24n2QmJ0XVxUdnNiVKYMlGtASWqr7056o2KmqcsrWeUX1iqSu1o4djvOtJt+7EsI1qUlx2h1A/3j/... |
701,163 | Longest Consecutive 1's | Given a number N. Find the length of the longest consecutive 1s in its binary representation.
Examples:
Input:
N = 14
Output:
3
Explanation:
Binary representation of 14 is
1110, in which 111 is the longest
consecutive set bits of length is 3.
Input:
N = 222
Output:
4
Explanation:
Binary representation of222 is ... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public static int maxConsecutiveOnes(int N)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass Main {\n \n\tpublic sta... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"maxConsecutiveOnes(self, N)"
],
"initial_code": "# Initial Template for Python 3\n\nimport math\n\n\ndef main():\n T = int(input())\n\n while T > 0:\n n = int(input())\n obj = Solution()\n print(obj.... | eJxrYJlawsIABhG5QEZ0tVJmXkFpiZKVgpJhTJ5BTJ6SjoJSakVBanJJakp8fmkJVBIoUweUrNVRQNVhiFOHIQ4dRiTrMMapwwiXqwyMcGsyxOUXIwMTc9y6cLrOyNwMjzZTHNrMTE2NTXFrM8PpMxMLU3PcGo1weQ63E41xRxRhd+LQa4AvZeBMS+BYI6QbZ/QBfUiJF2NIT8eGELeSa4IB1NGkBq4hVttJzSMwE/Io8wAEEeON2Cl6AI2Ia6Y= |
703,149 | Sid and his prime money | Given an array arr[] of selling prices in the cities, find the longest subsequence of consecutive cities where prices are strictly increasing. Also, calculate the maximum sum of prime numbers in that subsequence. If multiple subsequences have the same length, choose the one with the highest prime sum. If no primes are ... | geeksforgeeks | Hard | {
"class_name": "Solution",
"created_at_timestamp": 1616524384,
"func_sign": [
"public static List<Integer> primeMoney(int arr[])"
],
"initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass ... | {
"class_name": "Solution",
"created_at_timestamp": 1616524384,
"func_sign": [
"primeMoney(self, arr)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input()) # Read the number of test cases\n while t > 0:\n arr = list(map(int, input().split()))... | eJy9VctuFDEQ5MCBzyjNEUWR2267bb4kEos4wB64LDlspEhRIj4C/jflHjY8lN5sgsTMdtsz9rinyjW1317/kDev/Lh4y877m+XL7vJqv7zDIpudoCCjokEEBimQgZyRBbkiK/JAYb8j23KGZXt9uf20337++PVq/3MVRRmb3d1mt9ye4a/VU4IkYWQG107KqAzWSyyXOmOwNufxBUQ4b76DcJ7UoKA01FKCkhXqkByNTkBEwCo2AQphJOTiwNoEVtLEJiMoZWg1xkZ0gwdmVzwXz+Z5zMGJL4kPig9K9RyRSc452oKaxaACLVB2MlSh... |
703,679 | Number of edges in a Planar Graph | On a wall, there are C circles. You need to connect various circles using straight lines so that the resulting figure is a planar graph with exactly F faces. Print the units digit of number of edges we can draw between various circles so as the resulting graph is planar with F faces.
Examples:
Input:
C =
"6" ,
F =
... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int findNoOfEdges(String C, String F)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nimport java.lang.*;\n\nclass GFG {\n public static void main(String args[]) throws IOE... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"findNoOfEdges(self, C , F)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n C, F = map(str, input().split())\n\n ob = Solution()\n... | eJytVMtOxDAM5ID4DqsnDitwm0cTvgSJIA7QA5ewh660EgLxEfC/TL2sKGzcUmAsRankmXEsuy/Hb+cnR4LLU1yuHqv7vN701QVVJuUIUGi9S7lujCXn24ArAxQGpFytqOq26+627+5uHjb9B7lJ+TllltPLWT2taKSOhMYNOqKGRCuqZvehqAZRCiU9m7KxzlMbIvgRRZOzBi41QA2ABIAsoBrYUcG1nK5khtY4gDyQcgvQrhvSsMFRdYiiZ/SHDL1mBDWMQCojyDICrowgzwj4MoICI+DMCBKm6j1+0WwdSK5J12KFE6UFcqrc4kDU... |
703,186 | Pair the minimum | Given an array arr[] of size 2n, where n is a positive integer, the task is to divide the array into n pairs such that the maximum sum of any pair is minimized.Examples:
Examples:
Input:
arr[] = [5, 8, 3, 9]
Output:
13
Explanation:
Possible pairs:
Case 1: (8, 9), (3, 5) → max sum: 17
Case 2: (5, 9), (3, 8) → max su... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1616693371,
"func_sign": [
"public static int Pair_minimum(int arr[])"
],
"initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass GFG {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1616693371,
"func_sign": [
"Pair_minimum(self, arr)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input())\n while t > 0:\n arr = list(map(int, input().split()))\n ob = Solution()\n ... | eJytVEEOgjAQ9MBDNj2j6RZ6wJeYiPGgHLwgB0hMjMZH6Oe8+RPbRaIxDAhxmyxturPdnSm9BLdHMBFb3N1keVS7vKhKNSfFac7E2htZ8Ym3NFchqexQZJsy2673VdnEx/X22UWcQvrKVOdp+8CE5rXdnpBkYDDEGYoohjiLz/MVe48Z0Izbd1jriRyBFt4b0j4XOFfSpUWNFlG9wyT6ONwSGU2RphiXYZF6lmR0HAxr1/+9kgA5xVpwMhTDgwGOW4a1Gcb0DG9Irl3fX4HRbz2SHwSRIFyJ4TGSyEPQ8wysrrMn2CdxHA== |
702,823 | Chocolate Distribution Problem | Given an array A[ ] of positive integers of size N, where each value represents the number of chocolates in a packet. Each packet can have a variable number of chocolates. There are M students, the task is to distribute chocolate packets among M studentssuch that :1. Each student gets exactly one packet.2. The differen... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1729287951,
"func_sign": [
"public int findMinDiff(ArrayList<Integer> arr, int m)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GfG {\n public static void main(String[] args) throws Exception {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1729287951,
"func_sign": [
"findMinDiff(self, arr,M)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n\n for _ in range(t):\n A = [int(x) for x in input().split()]\n M = int(input(... | eJy1lU1ugzAQhbuo1FtEI0vdJVXGYAM9SaW66iJh0c00CyJFihL1EM19YxzxWw8EJ/WwMAjevPnsMT+Pp+enBzfeZnbyvhdftNkW4hUEGsJlNSCrBiDI9t3fV1JDkZiDyHebfFXk68/vbdFoHg2Jwxx6iaxmBDEo0JBACqWuoYxRSTkVn93aVdvqJV/zwJBickkmVwQjwUsuGUmlAUtbDN7E8rHlWDroQumy4nsg8q2hQ9QmNsjWUDKRH0IvPPqG5H8jrC/riEumonGY49Mmpu+M6lNZh688Q/Etug6fZhQWfOd2JeAOGkrjZI3hbsxu... |
711,971 | Maximum Connected group | You are given a squarebinary grid. A grid is considered binary if every value in the grid is either1 or 0.You can changeat most onecell in the grid from0 to 1.You need to find the largest group of connected1's.Two cells are said to be connected if both areadjacent(top, bottom, left, right)to each other and both have th... | geeksforgeeks | Hard | {
"class_name": "Solution",
"created_at_timestamp": 1661770666,
"func_sign": [
"public int MaxConnection(int grid[][])"
],
"initial_code": "import java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n Scanner sc = new ... | {
"class_name": "Solution",
"created_at_timestamp": 1668177573,
"func_sign": [
"MaxConnection(self, grid : List[List[int]]) -> int"
],
"initial_code": "class IntMatrix:\n\n def __init__(self) -> None:\n pass\n\n def Input(self, n, m):\n matrix = []\n # matrix input\n for ... | eJxrYJlaz8oABhEVQEZ0tVJmXkFpiZKVgpJhTB4QGSjpKCilVhSkJpekpsTnl5YgZOti8pRqdRQwtBiSqMUIqEXBAGiVAi7LjHDrNIDoxGUnLp3GYJ1QW+EUiQ43Bjkc7HRDwoaY4DDEBKoNrh8Lg1TfmUBchHAaCgNqOA4zTXGYaQrXiGQGYSapTjeFhCkYkmIjDmvM8CRTXE4zwKbHAJcN6Opi8nBmAAwjaRH9BrjzLPZggEStKam5FuZ6bMkN5gEDQwPCFmANbjwlD/boAQU71RMphb6GeBtPhMC8EjtFDwAQl5aS |
703,622 | Ways to split string such that each partition starts with distinct letter | Given a string S. Letkbe the maximum number of partitions possible of the given string with each partition starts with a distinct letter. The task is to find the number of ways string S can be split intokpartition (non-empty) such that each partition starts with a distinct letter. Print number modulo1000000007.
Example... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int waysToSplit(String S)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nimport java.lang.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"waysToSplit(self, S)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n S = input()\n ob = Solution()\n print(ob.waysToSplit(... | eJy1U1tOwzAQ5AOJa1T5rhBtXpSTIBGE4kfecZzETuwiEIeAm/HHZWgprUjbTRsKo3zYSjK7szvzcv72cXH2hdv3xeHu0YgZl8K4GRkTj/k+QhgTQmkQhKHHjPHIoIpTLCh5KKT4/tKxPPa8ePs0Hm39jzChQRjFSZrlrOBlVQvZtErPQa4JRNUB+gncAemAdgBWNW3HnQKV5zvQ21AKZh4+G63aRoq6KnnB8ixN4igMKMHIh4fmuK47nTiQAqUBRrgJeEOmaduWZULj6nomiuI4SdI0y/KcsaLgvCyrqq6FkLJp2lYpfUothA8+8NAs... |
704,550 | Subsets with XOR value | Given an array arrof N integersand an integerK, find the number of subsets of arr having XOR of elements as K.
Examples:
Input:
N = 4
k = 6
arr: 6 9 4 2
Output:
2
Explanation:
The subsets are
{4,2} and {6}
Input:
N = 5
K = 4
arr:
1 2 3 4 5
Output:
4
Explanation:
The subsets are {1, 5},
{4}, {1, 2, 3, 4},
and {2... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int subsetXOR(int arr[], int N, int K)"
],
"initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*;\n//Position this line where user code will be pasted.\nclass GFG\n{\n public static void... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"subsetXOR(self, arr, N, K)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N, K = input().split()\n N = int(N)\n K = int(K... | eJzFVcuOEzEQ5MCFvyjNeYXc7ce0+RIkBnGAHLgMe8hKSAjER8A/ceOXqLZDWLJxNloCZKSMx+Ppqq7qtj8//vr9yaP2e/6Ngxcfprfr9c12eoYpLmvGvKyimFEgGbasvIdlDRAoIhLysiZw5dye83SFafP+evN6u3nz6t3NdhdKl/UTv2r/fTx9vMItLE4aMhfUimwgZMrQiDLDKkScihJLImSGVH+ndYDWcWSAIwExeDwOmJMGBuYMYkYKDus0SKD4jVklkE9B5EwiMePygswFEjTx82QDGlLGPJpiEhwiBDDpaqgzakHNqIk6IGfX... |
703,124 | Smaller and Larger | Given a sorted array arr and a value x, return an array of size 2. The first value is the number of elements less than or equal to x, and the second value is the number of elements greater than or equal to x.
Examples:
Input:
arr[] = [1, 2, 8, 10, 11, 12, 19],
x = 0
Output:
0, 7
Explanation:
There are no elements les... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int[] getMoreAndLess(int[] arr, int x)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\npublic class GFG {\n public static void main(String[] args) throws IOException {\n Scanner sc = new Scanner(System... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"getMoreAndLess(self, arr, x)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n arr = list(map(int, input().strip().split()))\n x = int(... | eJytlM9KxDAQxj3oe3zkvEgmaZLWJxGseNAevNQ9dGFBFB9CX9Wb4JeuCrJMmnVND9OSyS/z55u+nL59nJ3M6/KdL1eP5n5cbyZzASP9KNh7+tH2o1nBDNv1cDsNdzcPm+nrhIVw85n7TytUkEQlSQHl0CCiRfZxkAYSIS0c/Z0eW/ZWY3PwhAZiE8HdfHdQUfRTSZ6UlAlM0EMCJEE6RqYHhk6j2byY2Gz8zjQ7E2bz7aOnHaB2JJNJJZE0RItk0Vp0ufQ5/1IBggYtNlXvwIKqDhLVQkWYd1lZDeoUldS4yAn/KFGr+P9lOsS5wwdE... |
703,852 | Ceil The Floor | Given an unsorted array arr[] of integers and an integer x, find the floor and ceiling of x in arr[].
Examples:
Input:
x = 7 , arr[] = [5, 6, 8, 9, 6, 5, 5, 6]
Output:
6, 8
Explanation:
Floor of 7 is 6 and ceil of 7 is 8.
Input:
x = 10 , arr[] = [5, 6, 8, 8, 6, 5, 5, 6]
Output:
8, -1
Explanation:
Floor of 10 is 8... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1728109714,
"func_sign": [
"public int[] getFloorAndCeil(int x, int[] arr)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws IOException {\n BufferedReader br = ne... | {
"class_name": "Solution",
"created_at_timestamp": 1728109714,
"func_sign": [
"getFloorAndCeil(self, x: int, arr: list) -> list"
],
"initial_code": "# Initial Template for Python 3\ndef main():\n t = int(input())\n for _ in range(t):\n x = int(input())\n arr = list(map(int, input().sp... | eJytVMtOwzAQ5ID4jlHOLVq7dh58BDckJIo4QA9cQg+thIRAfAT8L/toopZkA5Xq5BDHu7OPmfXn+ffNxZmu22v+uHsrntv1dlNcoYjLNtCyzShR81Mi81PyzywHiIQFIREyoSRUhJrQEAKxUzFDsXpdrx43q6eHl+1mB1ljHpbtx85fv4r3GfaC8nGjS2x0Qbc1h9FdQHfuxLDj3mo0RCaFR2qQA0NKES5gttNRIHsdR0b23Ky0rlb0ew9p14rebho1IGKBJHShYuokwAR2R8pIn5SphiEq5T8xbIRfMSvEQYqS10JaTtJOLYUlIBoS... |
702,698 | Last seen array element | Given an array arr[] of integers that might contain duplicates, find the element whose last appearance is earliest.
Examples:
Input:
arr[] = [10, 30, 20, 10, 20]
Output:
30
Explanation:
The element 30 has the earliest last appearance at index 1. Therefore, the output is 30. Even though 10 and 20 appear multiple time... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public static int lastSeenElement(int arr[])"
],
"initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass GFG {... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"lastSeenElement(self, arr)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input())\n\n while t > 0:\n arr = list(map(int, input().split()))\n ob = Solution()\... | eJzFVEtOwzAQZYHENZ6yrlBsj+OUkyBRxAK6YBNYtBISAnEIOAE7TsnzmKYq0rglIPHsKHbiefP1vBy/fZwcKc7fubh4bG6H+/WqOUPjFoNrFZgrsLPtyys1MzTLh/vl9Wp5c3W3Xn1JF5HF8LwYmqcZvvHCI0AQ0SGBTKSGM5i8QVKEdyjKy+CJljF0iJKJRJE2Bdo22mdQudbmKtNvZtApOqNlWoWvRNyNsffjKowr2awseiuCFJ1DekiCdBC6LxA67iEO1b9WjCuOMBo5FjkSORQtOj6JT59LKjupnuaTzpdtTcSqu9Y0wQf6ECV4... |
702,051 | Top K Frequent in Array | Given a non-empty array arr[] of integers, find the top k elements which have the highest frequency in the array. If two numbers have the same frequencies, then the larger number should be given more preference.
Examples:
Input:
k = 2,
arr[] = [1, 1, 1, 3, 3, 4]
Output:
[1, 3]
Explanation:
Elements 1 and 3 have the s... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1727681526,
"func_sign": [
"public ArrayList<Integer> topKFrequent(int[] arr, int k)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\npublic class Main {\n public static void main(Stri... | {
"class_name": "Solution",
"created_at_timestamp": 1727681526,
"func_sign": [
"topKFrequent(self, arr, k)"
],
"initial_code": "# Initial Template for Python 3\n\nimport atexit\nimport io\nimport sys\nfrom collections import deque\n\n# Contributed by : Nagendra Jha\n\n_INPUT_LINES = sys.stdin.read().split... | eJytVEGOwjAM7AF4h5UzQoQkQHkJEkUcoAcugUORkNCu9hHLdxGxCxEB2S2CuDdPJuPpJH+dc7eX0Zpfulm2OKmt3x8qNQOlC4/fEJfqgyqP+3JdlZvV7lDdIdSEwv8WXv30Id1tCu8Ay4QaYTE0LvQMx+KCBupbcOx+SydojmN0V4JIG/Vo0AIjw2VRj6b9hlTZG3OTOt4lPYT6y6mmVBOqMRbrPoEF32oAskSLZC6E8h7muKBNImokw6Tj32Ad4716GAViLliLarTskGxMaAeQmC6keneSNEUPMZqIORJUPOdo+laQENZaqmuhFZW6... |
703,723 | Days of Our Lives | Given a month with arbitrary number of days, N, and an integerK representing the day with which it starts. ie- 1 for Monday, 2 for Tuesday and so on.Find the number of times each day(Monday, Tuesday, ..., Sunday) appears in the month.
Examples:
Input:
N =
31 ,
K =
1
Output:
5 5 5 4 4 4 4
Explanation:
The month s... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int[] daysOfWeeks(int N , int K)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n Buffer... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"daysOfWeeks(self, N ,K)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N, K = map(int, input().split())\n ob = Solution()\n ... | eJytVEsOgjAQdaH3mHRNDG0tNp7ERIwLZeGmsoDExGg8hB7AnceUtiAfM1MWtkMhNO/No/OG+/T5nk3cWL+qh82FHU1eFmwFjKeGA2cRsOycZ/siO+xOZdFsQtzO1NxSw64RDNFLBN3BAkfQSyJ3Z6JoLPcYtEZzi1HoMbkFgpaJQrMrCUoMgqDBZPxwgJJYDWM78FIshE6AWpVfaXr0vMLE/g1eR7dg/GOqWe2QfqpdTHaCxg3FJbQhfBBKuoLCqmpluEUk4RFrjOHF7T0s71vZv+jU7oOJI/T9RPck8UPonb0LrBuskt7HBfpcUL4K... |
700,380 | Count Palindromic Subsequences | Given a string str of length N,you have to find numberofpalindromic subsequence (need not necessarily be distinct) present in the string str.
Note: You have to return the answer module 10**9+7;
Examples:
Input:
Str = "abcd"
Output:
4
Explanation:
palindromic subsequence are : "a" ,"b", "c" ,"d"
Input:
Str = "aab"
... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1731585456,
"func_sign": [
"int countPS(String s)"
],
"initial_code": "import java.util.*;\n\nclass GFG {\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n int t = sc.nextInt();\n sc.nextLine();\n... | {
"class_name": "Solution",
"created_at_timestamp": 1731585456,
"func_sign": [
"countPS(self,s)"
],
"initial_code": "# Initial template for Python 3\n\nimport sys\n\nsys.setrecursionlimit(2000) # Increase limit as needed\n\nif __name__ == '__main__':\n t = int(input())\n for i in range(t):\n ... | eJxrYJl6g58BDCIuAhnR1UqZeQWlJUpWCkqGMXmJSjoKSqkVBanJJakp8fmlJQgppVodBVTFVXCAS5eBkTE2jYlJmBCHEaaWBiYW2M1ITklNS8/IzMrOyc3LLygsKi7BYYaRAVYDEnF51hyb8qLE5NTkxCJcVlhityIpCactxliDpqKysgKEK3EFqTFW1yFCA8HCZQKO4MASJ0MF4ooUC1NDMzMDY+xxg2LCEA8A/MFgaIEjzQynEIDkaCqEw0B7hEaeN7AwMzM2N8JaloLLtqGUALAK4iqbB8jLgyU8B9wBSM6A14nosiTFHbCKg9Zx... |
705,047 | Circular Prime Number | Find all circular primes less than given number n. A prime number is aCircular Prime Numberif all of its possible rotations itself are prime numbers.
Examples:
Input:
n = 4
Output:
[2, 3]
Explanation:
2 and 3 are the circuler prime number less than 4.
Input:
n = 7
Output:
[2, 3, 5]
Explanation:
2, 3 and 5 are the... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1727981375,
"func_sign": [
"public ArrayList<Integer> isCircularPrime(int n)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throw... | {
"class_name": "Solution",
"created_at_timestamp": 1727981375,
"func_sign": [
"isCircularPrime(self, n)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n = int(input())\n ob = Solution()\n ans = ob.isC... | eJzVVctKxEAQ9ODFvyjmvEg6gwzlT3gTwYgHzcFL3EMWBBH8iN3/tToIIsxksw+XGEjoTFfX9KSayuf55vbibLjubhTcv4eXbrnqwzWCNV0dFgjt27J96tvnx9dV/51quvCxwG+sVQVwjYgrpGxNHK+BWX6rLXupDhZhCdEQE5IhRSSC2TbItDefUkpo2TwmhRBEmOgIo4ARNIcayNJ59j/QcRrQ6u7qVafsW3iqgE6kUDDR6HY6VdHLFRQE1jW7TgccHeg15MA48NPLPHReJ6Mn4EDfQS9FPeYnyF8c819NX72TxYww+HOCZZZ5rDrU... |
705,195 | Longest valid Parentheses | Given a string str consisting of opening and closing parenthesis '(' and ')'. Find length of the longest valid parenthesis substring.
Examples:
Input:
str = ((()
Output:
2
Explanation:
The longest valid parenthesis substring is "()".
Input:
str = )()())
Output:
4
Explanation:
The longest valid parenthesis substri... | geeksforgeeks | Hard | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int maxLength(String S)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG{\n public static void main(String args[])throws IOException\n {\n BufferedRead... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"maxLength(self, str)"
],
"initial_code": "# Initial Template for Python3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n S = input()\n\n ob = Solution()\n print(ob.maxLength(S... | eJy1Vs1OhDAQ9uDJpyA9zSQbw58b4sWbz2AixoNy8IJ7YBMTo/Eh9H2l0ynMLm2lLpRNCzTM9zPDsF/nP7cXZzTubvqT+3f10u72nbpO1FXdAgAi6hWBVjQH7ZhN2te75hJAbRLVvO2ap655fnzddxxtW7efdWvmiuYsF7fUxyYR2AVh6nAIBGsumAQaPn6wUkR2xi+tgqOB09GrI0Ac5Y5skB7SBoC91hN6eBWV0G+IZaVP/4FWC6p/4I0vHXXGzVkNxZ16YAQGTeWsHcUVtYIiWa6iGTzkHPrgZKlwwaRycWSUkRmSEdk0HNUGVUrz... |
700,219 | Undirected Graph Cycle | Given an undirected graph with V vertices labelled from 0 to V-1 and E edges, check whether it contains any cycle or not. Graph is in the form of adjacency list where adj[i] contains all the nodes ith node is having edge with.
Examples:
Input:
V = 5, E = 5
adj = [[1], [0, 2, 4], [1, 3], [2, 4], [1, 3]]
Output:
1
Expl... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public boolean isCycle(ArrayList<ArrayList<Integer>> adj)"
],
"initial_code": "import java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"isCycle(self, V: int, adj: List[List[int]]) -> bool"
],
"initial_code": "if __name__ == '__main__':\n T = int(input())\n for i in range(T):\n V, E = map(int, input().split())\n adj = [[] for i in range(V)]\... | eJzt202uLNlZRmEaDGSr2hbK+I9gJEhcRAPcoHNxw5aQEBItRgBzpMcUeNYul0C4bHzBQraIarx6G+esuidzr4zY3478xz/+l3/7pz+a//3Zvyp//vff/c3Xn/3i59/96fhu+fJ1+XzG/uXrZ9TH+uXrOrYvX7fx+fL1u5+M7376dz/76V/9/Kd//Zd/+4uf/8cvffcPPxn/FTOeH6Eg7+P48vUY55ev57i+fL3G/eXr3Q//Gvznx/D3WNYf/0f+Cn7vR/Z+5OhHzn7t+rY/5pj/o/UY+zf+M3sxn299HZ6xfOYLuPRLy/xLl3UsfnHZ... |
704,603 | Get Minimum Squares | Given a number n, find the minimum number of perfect squares (square of an integer) that sum up to n.
Examples:
Input:
n = 100
Output:
1
Explanation:
10 * 10 = 100
Input:
n = 6
Output:
3
Explanation =
1 * 1 + 1 * 1 + 2 * 2 = 6
Constraints:
1 <= n <= 10**4 | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int MinSquares(int n)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"MinSquares(self, n)"
],
"initial_code": "# Initial Template for Python 3\n\nfrom math import ceil, sqrt\nimport sys\nsys.setrecursionlimit(10**6)\n\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n ... | eJydk0EKwjAQRV30ICXrIk3StKknEYy40Cy6iV20UBDFQ+h9TUwVuvgjcZhFIbzJ/3+ae/bss9W7tp3/2F1Y5/pxYJucceO4kKzImZ16exzs6XAeh/lQGnczjl2LfEm0vgBSAUT7SrylUYmAKgEgACBUDQgOCFkKpAohrS55IlI3GuWLvFdSoFuQe7/3P0KO3Si0TcJTTBw5QzKDs5gip6OhB4ROJXV0Cv9c5NV3SJfQCsnZ4s8BaD1fyXypg3h/SAsxin7Qn4H7x/oFJRthog== |
704,896 | Number of ways to find two numbers | Given a positive integer K. Find the number of ordered pairs of positive integers (a,b) where 1≤a<b<K such that a+b ≤ K.
Examples:
Input:
K =
2
Output:
0
Explanation:
There are no solutions for K = 2.
Input:
K =
4
Output:
2
Explanation:
There are 2 solutions:- (1,2) and (1,3).
Constraints:
1 <= K <= 10**5 | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static Long numOfWays(int K)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader re... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"numOfWays(self, K)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n K = int(input())\n ob = Solution()\n print(ob.numOfWays... | eJzFk0FOwzAQRVkgcY3I6wrZ09hpehIkjFhAFmxMF6mEhEA9BFyGHTdj7HFNEnmciEXwJmmd+fP8Pf90+fl9dRHWzRe+3L6KJ3c49mJfCWWdklJsKtG9HLqHvnu8fz72cRNqLa17t068bapxkWaLDABb1frFNsM9iUsxxcpv8qhYrf0HueqtdeCZAzcnQZUmKhioG51X06gmAw9BRbQZwpa0kqdIfNb38FoOfvAniSbuCjbsfDEwNkThhtqV7gMNaJtEpWppQMGQmL8sNAj/ByoedyxaFFtpA9vk/TwG6xXQARt6mJJlXqJOkqGfYRw8... |
714,129 | Special Palindrome Substrings | Given two strings s1 and s2, The task is to convert s1 into a palindrome such that s1 contain s2 as a substring in a minimum number of operation.
In asingle operation, we can replace any word of s1 with any character.
Examples:
Input:
s1="abaa" s2="bb"
Output:
1
Explanation:
we can replace s1[2]='a' with 'b'.
So the... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1677586392,
"func_sign": [
"public static int specialPalindrome(String a, String b)"
],
"initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\nclass GFG {\n \n\tpublic static void main (String[]... | {
"class_name": "Solution",
"created_at_timestamp": 1677586392,
"func_sign": [
"specialPalindrome(self,s1, s2)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input())\n for _ in range(t):\n s1, s2 = input().split()\n obj = Solution()\n ... | eJydlFtOwzAQRfmAfVj+LohWvMRKkChCfrV1mjhu6rRJEIhFwD74Y3s4D6qW9rottuLxj0/m3hn7/fTz++ykGQ9ffvP4QrWxuaP3hPaHhnEh1Wg80ZGOpnFiUjvL5o7ki2VRVs4H2iNUFVYJp+Rzmrvu6MCffRsa+tojm8CqLJaL3M2zmU1NEk8jPRmPlBScEc4EoPWvAY21g3Pe7RipF4RBlFZkF0gbAeMGMnidByNCCgnO3gX+7+3sAvFfWSAJl4BRlOvTMyDiFhAsi7WRWZoolaSZNDpmljRbAMKpVF7AaiXNDjBwYTkXQkqlhPAl... |
703,643 | Encrypt the string - 2 | You are given a string S. Every sub-string of identical letters is replaced by a single instance of that letter followed by the hexadecimal representation of the number of occurrences of that letter. Then, the string thus obtained is further encrypted by reversing it [ See the sample for more clarity ]. Print the Encry... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static String encryptString(String S)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nimport java.lang.*;\n\nclass GFG {\n public static void main(String args[]) throws IOExceptio... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"encryptString(self, S)"
],
"initial_code": "if __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n S = input()\n ob = Solution()\n print(ob.encryptString(S))\n print(\"~\")\n",
... | eJylVO1Kw0AQ9Ifga5T4T4owB6L4r28hWJHc5e7y1UuaJmkaUXwIfV+vQqqV7uUwGwKBsDO7O7P7fv55dXH2HQ+X9uPxJUhM2dTB/SzA0oTBfBbIrpSiltFz0dTDr3Bp3pYmeJ3P/iRwKoM7ckQklaYSNRQkIggHRL/rtm1Tb6p1WZhVnqVJrJWMBKcbsGjCokqLrhEjQYoMOVYwKFBijQob1GjQYosOO/Tu8uMkzfKVKUqKsbS4xuLnlie1fLFXZ4tDELjhgprJIahMuqNTj0NY35fiCzkXIoqkVErrOE6SNM0ygo9lLGUJi5lmikkW... |
704,704 | Brain Game | 2 players A andB taketurns alternatively to play a game in which they have N numbers on a paper. In one turn, a player can replace one of the numbers by any of its factor (except for 1 & the number itself).The player who is unable to make a move looses the game. Find the winner of the game if A starts the game and both... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public boolean brainGame(int[] nums)"
],
"initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG\n{\n public static void main(String[] args) throws IOException\... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"brainGame(self, nums)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n = int(input())\n nums = list(map(int, input().split()))\n... | eJydk8FKxDAQhj3oe/zEmyySmaTtxJs+hWDFg/bgpe6hC4Is+BD6vv7ZLVKxhWZLfwjpP9MvM5PP8++ri7PDc3/JxcOHe+23u8HdwEnb81W3gevet93z0L08ve2G8etd27v9Bn/92vYpJYj3fiHsdi5MPEMRUKGBCCRAuEjQAE0l/6/avoYhE0CWyGcRQiZvkJIV08d8AO+RT57jmacknMwSoQKtoA1CceXEK5kjVVE1xTPkAgj3mVqE+1LEJISKmJQSOQ/TMLtBPVSh8UBsJXnVHwdkLBNVUxUVqUApJRTLafQZfUaf0Wf0GX1Gn9Fn... |
715,457 | Find Kth permutation | Given two integersN(1<=N<=9) andK. Find the kth permutation sequence of first N natural numbers. Return the answer instringformat.
Examples:
Input:
N =
4, K = 3
Output:
1324
Explanation:
Permutations of first 4 natural numbers:
1234,1243,1324,1342,1423,1432.....
So the 3rd permutation is 1324.
Input:
N = 3, K = 5
Out... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1685961077,
"func_sign": [
"public static String kthPermutation(int n,int k)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n//Position this line where user code will be pasted.\n\nclass IntArray\n{\n public static int[] input(BufferedRea... | {
"class_name": "Solution",
"created_at_timestamp": 1685961077,
"func_sign": [
"kthPermutation(self, n : int, k : int) -> str"
],
"initial_code": "# Initial Template for Python 3\n# Position this line where user code will be pasted.\nif __name__ == \"__main__\":\n t = int(input())\n for _ in range(t... | eJy1lEFOxDAMRVnAPaKsRyixHSeZkyBRxAK6YBNm0ZGQEGgOARdkxy1I2kKpwGlB0FWr6j//fNs5HD+/nhz1z9lLfjm/1zdpt+/0VmnbJKus3ijd3u3aq669vrzdd9PPxybph42aK6KsACTHPkRRiQwhGEEeg2dHCN8Wht7qImPQVknYJKfYNIkUUC0ABEcD4QMlWYuqL9mkoMggSO7QebAUOfSYBZM+o0y2ycqDGTwLWCZw6AfOJ+Tk/2srytkFWqUD7+H3QxAs0bpWOirfAtaWo1kjkZxFglpC42HGoIrJ5bC8xTGhsa2Ajn5RxPxz... |
703,465 | Delete array elements which are smaller than next or become smaller | Given an array arr[] and a number k. The task is to delete k elements that are smaller than the next element (i.e., we delete arr[i] if arr[i] < arr[i+1]) or become smaller than the next because the next element is deleted.
Examples:
Input:
arr[] = [20, 10, 25, 30, 40], k = 2
Output:
[25, 30, 40]
Explanation:
First ... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public static ArrayList<Integer> deleteElement(int arr[], int k)"
],
"initial_code": "// Initial Template for Java\n\n// Initial Template for Java\n\n/*package whatever //do not write package name here */\nimport java.io.*;\ni... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"deleteElement(self,arr,k)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n arr = list(map(int, input().strip().split()))\n k = int(inp... | eJytVEtOw0AMZYE4x9OsK2TP5DecBIkgFpAFm9BFKlVCIA4B12DH/bAnEU2rmUkq0UXVz7P9PnY+Lr9+ri7C6/ZbPty9mud+uxvMDQy3fUmwBEdgQkGoCRW1vTMbmG6/7R6H7unhZTdMBeUc9N725m2Dk36wqODgIV9sos0fINqCieAJzTQI41AXiLLMLRNdl+riw4SKRYkCtfBu1Abf9kVK/xEq3lAcsGDpWsPJuwyQX5zycJwmL9AjXLT3TI6qq4LSRlVnKJ/g4qQZHEhzARGg8kSlalVn1CEB1SnfUwXJdC2pEI1HdShBZagUlaPK... |
704,778 | Number of Integer solutions | You are given a positive integer N and you have to find the number of non negative integral solutions to a+b+c=N.
Examples:
Input:
N =
10
Output:
66
Explanation:
There are 66 possible solutions.
Input:
N =
20
Output:
231
Explanation:
There are 231 possible solutions.
Constraints:
1 <= N <= 10**9 | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static Long noOfIntSols(Long N)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"noOfIntSols(self, N)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n\n ob = Solution()\n print(ob.noOfI... | eJy1VMuqwjAQdSH4GyVrkWaaqb33E9y5E4y40C7cVBcVhMsVP0L/17FJtWqmTX2EQAPpOZMz5ySH7mnc6xRjMqLF9E+sss02F7+BkDqjKfqBSHebdJGny/l6m9vNSGd72vzvB/cIYBExg5BhOVgo2h/kdeHiotJE8VMOls2AS6oQb+WfOUkmTTp6DZ0BQmJokZGJvDwZgbM5RhDvgRHidAIqAr16Avb3IVY77N0kuBVJvCw1glUJuuf38xuL3kDRAUWghqyaitYtaWwCJ7FTTzUJb2pTGMqGtLH+ecZQRcOW0nT8fXGX0l4a6QOts6Ri... |
702,831 | Minimum Steps | You are standing at the bottom of a staircase with exactly n stairs. You can take steps of size p or q at a time. Your task is to calculate the minimum number of steps required to reach exactly the n-th stair using only these step sizes. You can take any combination of steps of size p and q to achieve this.
Examples:
I... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int moves(int n, int p, int q)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n Buffere... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"moves(self, n, p, q)"
],
"initial_code": "# Initial Template for Python 3\n\ndef main():\n T = int(input())\n while T > 0:\n sz = [int(x) for x in input().strip().split()]\n n, p, q = sz[0], sz[1], sz[2]\n ... | eJydk00OgjAQhV3oPZqu0dCWongSEzEulIUbZAEJifHnEHpfKW1JUF75mUVpQufrzHvT1/zzXMzq2JXVZn+jlzQrcrollMUp81WQSEW9buKUeoQmZZac8uR8vBa5Ob2sjj+qv3ePtBk6WdagQO0hggOCqYITAVNFFYE7nRG9gQzUgM03n6n5XDYrRPS0oEUUzi6QiNKKADOl5v5nc2uiUlmQUMWotnRNnc3xpjJN0zUYdus+5HxNhdOnSLxvdJDs0YjZ7VQOMASuBnLYkFeglFpDJdiAZ+QE/BqOZ8npdTjZbGOzy23pDxxKDBmgk0Mm... |
706,297 | Construct list using given q XOR queries | Given a list s that initially contains only a single value 0. There will be q queries of the following types:
Examples:
Input:
q = 5
queries[] = {{0, 6}, {0, 3}, {0, 2}, {1, 4}, {1, 5}}
Output:
1 2 3 7
Explanation:
[0] (initial value)
[0 6] (add 6 to list)
[0 6 3] (add 3 to list)
[0 6 3 2] (add 2 to list)
[4 2 7 6] ... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1616471777,
"func_sign": [
"public static ArrayList<Integer> constructList(int q, int[][] queries)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass IntMatrix {\n public static int[][] input(BufferedReader br, int n, int m) throws I... | {
"class_name": "Solution",
"created_at_timestamp": 1616471777,
"func_sign": [
"constructList(self, q : int, queries : List[List[int]]) -> List[int]"
],
"initial_code": "class IntMatrix:\n\n def __init__(self) -> None:\n pass\n\n def Input(self, n, m):\n matrix = []\n # matrix i... | eJy9VLFOxDAMZWDgK5BViQ2hOE6cli9B4hAD3MBSGA4JCYH4CPhfbKehBWE4hsM9Re45dt97dvKy/3Z0sGd2dijO+WN3M97db7pT6HA1YliNAVCXqEuSv4B0YX3tLRr0Patb1Bu6Y+jWD3frq836+vL2fjOVS8DQwwCIgASYYDU+r8bu6Ri+fDNqFQzNtPDQzEKRUubSDxbpC+dEES3SzAA3M8zNjEUzA95MI9xMI6WZUW3msENmZOKSIQ6sCDkDZY6BU+nlI4iUUxiAc8gcSuLqIQWca3uSmM55FhvNj+ZH88l8Mj8FrwMSY0gCh4Cl... |
704,794 | Compare two fractions | You are given a string str containing two fractions a/b and c/d, compare them and return the greater. If they are equal, then return "equal".
Examples:
Input:
str = "5/6, 11/45"
Output:
5/6
Explanation:
5/6=0.8333 and 11/45=0.2444, So 5/6 is greater fraction.
Input:
str = "8/1, 8/1"
Output:
equal
Explanation:
We c... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"String compareFrac(String str)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\nclass GFG {\n public static voi... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"compareFrac(self, str)"
],
"initial_code": "# Initial Template for Python 3\nimport re\n\nif __name__ == '__main__':\n ob = Solution()\n t = int(input())\n for _ in range(t):\n str = input()\n print(ob.c... | eJytVMFOwzAM5YD4jijniMbdeui+BAkjhKAHJBSG1EpIaBMfAZ/JjQ/ASZMmG0maVeuhtVPnOe/Z8efl9+/VhXlufsi4/eDPajv0fMP4CpWsQDB6oYIKpJSCQdW2Lbnk6BX67cwaFReMd+/b7rHvnu5fh94CdW/DwwuqvUYxu/cBgPH4TrAgc60ja8Hqao2Kdrjcfs98phz+Sv+fCNEXVUPhjfbXlK7RKz6vswrSWhhj+9UYPQK1yaVVF7yfyBPIZwOj4JaJdOBGCkujWLoYNtiOgAwOJLcetdAsxwhCwCSLkWMApVX1AVEcXWpTxEbK... |
703,025 | Rotate a Matrix | Given a N xN2D matrix Arr representing an image. Rotate the image by 90 degrees (anti-clockwise direction). You need to do this in place. Note that if you end up using an additional array, you will only receive the partial score.
Examples:
Input:
N = 3
Arr[][] = {{1, 2, 3}
{4, 5, 6}
{7, 8, 9}}
Output:
3 6 ... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"void rotateMatrix(int arr[][], int n)"
],
"initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.io.*;\n\npublic class Main {\n\n public static void main(String[] args) throws Exception {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"rotateMatrix(self,arr, n)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n n = int(input())\n inputLine = list(map(int, input().strip(... | eJztmLtuXUUUhilo6OhpllxHaM99hidBwogCUtCYFIkUCYF4CHhfvv8fG+W2j0ISgZU4cqRjnb1n1vpvszx/fP7Xl1995n/ffsGH7369+vnmybOnV9/EVbq+Scf1zSpRj8ixUowcdcQosWrMGqvH7NGOKDGPWCtGi1SitVgjyopcovCZl2bMGYufYJEULcUckY4YNXKOwaMjcoreokdfUXg+R2F5nuUbHpzReqwWM3qNmiPNSJQShepqdF47YlLYEa1Ez9FZf0XntRxtRl1ReblFLZGo8uC5GilH5pcUtUehDlZJkSmyRqnRYrA+X1IE... |
712,305 | Postfix to Prefix Conversion | You are given a string that represents the postfix form of a valid mathematical expression. Convert it to its prefix form.
Examples:
Input:
ABC/-AK/L-*
Output:
*-A/BC-/AKL
Explanation:
The above output is its valid prefix form.
Input:
ab+
Output:
+ab
Explanation:
The above output is its valid prefix form.
3<=pos... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1666246868,
"func_sign": [
"static String postToPre(String post_exp)"
],
"initial_code": "// Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.math.*;\nimport java.io.*;\n\nclass GFG {\n public static void main(String[... | {
"class_name": "Solution",
"created_at_timestamp": 1667286244,
"func_sign": [
"postToPre(self, post_exp)"
],
"initial_code": "# Initial Template for Python 3\n# Position this line where user code will be pasted.\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n postfix = ... | eJydlMlOAkEQhj0Yn4PMyVTRVrh6g1lAWdXZiCNmNrbDyAGSAaPxIfR97VFECNQwYU6ddNfXVf//93ycf9HF2c/nXsrF46sySWaLuXJdUipe4gcYQkRKuaTE6SwO53H0/LKYrw8QoB+EkZe8e4nyVi7t1qbLVbZPgqkWmMJyRX7A1FdrKmk6oFFv0ICFUL0x4AEa6QbIehTIALAmSNUQdEOSckC6bOPmttlqd7q9u/sHEwmEZTuuRHOtWWiT4zJMP4AwoniIYjQGtjlBYYTxEEZjrrVqDWV3KECVamnA66SqoGkMJZuITMsGdFzRJ7Yd... |
701,242 | Number of pairs | Given two positive integer arrays arr and brr, find the number of pairs such thatx**y > y**x(raised to power of) where x is an element from arr and y is an element from brr.Examples :
Examples:
Input:
arr[] = [2, 1, 6], brr[] = [1, 5]
Output:
3
Explanation:
The pairs which follow x
**y
> y
**x
are: 2
**1
> 1
**2
,... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1723359974,
"func_sign": [
"public long countPairs(int x[], int y[], int M, int N)"
],
"initial_code": "import java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass Main {\n public static void main(String[] args) throws Exception {\n Bu... | {
"class_name": "Solution",
"created_at_timestamp": 1616602787,
"func_sign": [
"countPairs(self,arr,brr)"
],
"initial_code": "# Initial Template for Python 3\n\nimport atexit\nimport io\nimport sys\nimport bisect\n\n_INPUT_LINES = sys.stdin.read().splitlines()\ninput = iter(_INPUT_LINES).__next__\n_OUTPUT... | eJy1VMtOwzAQ7IHHb4xyrpB3/eZLkAjiAD1wCT20EhJC4iPgdxHr1FFa1W4bVGrVctLueHd2Zz4vvi+vZ/3n7udqNrt/b1665XrV3KKhtiOlFGKM8g27T80czeJtuXhaLZ4fX9erHKPbrvmYYxfFSlgfqxHBvu3Snt9UcHwJhwXAwMLBIwgUqQQV5MnJWyO/MqiWmCshEk5a6eqTVuVyVavGSu4kF2iQHIQWKSFCE7SHIRip18PK/yIcwXl4gtfwUrVGkEb4VIOR+jd8gIQBA7IgBwpgBSawZGbAFuwS8RyghXm5X0MLaxbaVRJnZYu0... |
704,946 | Rectangle Number | We are given a N*M grid, print the number of rectangles in it modulo (10**9+7).
Examples:
Input:
N =
2,
M =
2
Output:
9
Explanation:
There are 4 rectangles of size 1 x 1
There are 2 rectangles of size 1 x 2
There are 2 rectangles of size 2 x 1
There is 1 rectangle of size 2 X 2.
Input:
N =
5,
M =
4
Output:
150
... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static long rectNum(long N, long M)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedRe... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"rectNum(self, N, M)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N, M = map(int, input().split())\n\n ob = Solution()\n ... | eJytVMtOxDAM5AD/EeW8QoljxzFfgsQiDtADl7KHroRAIPgH+F/ch3hJNguLD1Fax5OZsdunw9fno4MpTu90c3Yfr/vNdognIeZ1n5NGmNZ1H1chdreb7nLori5utsNyjFEqjflHPfKwCt8QoGCgys2sxwQa1USQxjUQFjARAKRRrtIsBI3QNGwEBhK9Ay0VP7pAQIANSvU4ZNsETVOyXQxj/Z+rpy6SSz817VSVbECAVgcmFwETZ0ELAUcO1eOgKjI1cwwWAz+LcXu6oynWVFMtjETiyUFXj7TKhSSxx2Caq/nBtlY/MQZxleR3oLlL... |
700,274 | Find kth element of spiral matrix | Given a matrix with n rows and m columns. Your task is to find the kth element which is obtained while traversing the matrix spirally. You need to complete the method findKwhich takes four arguments the first argument is the matrix A and the next two arguments will be n and m denoting the size of the matrix A and then ... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int findK(int A[][], int n, int m, int k)"
],
"initial_code": "import java.util.*;\n\nclass Find_Given_Element_Of_Spiral_Matrix \n{\n\tpublic static void main(String args[])\n\t{\n\t\tScanner sc = new Scanner(System.in);\n\t\t... | {
"class_name": "Solution",
"created_at_timestamp": 1687514176,
"func_sign": [
"findK(self, a, n, m, k)"
],
"initial_code": "# Initial Template for Python 3\n\nfor _ in range(int(input())):\n n, m, k = map(int, input().split())\n a = [\n list(map(int, input().split()))\n for _ in range... | eJztmMFuHUUQRVnwFaxKXmfQVFX3dF9WfAYSQSzACzYmC0dCQiA+Av6XU6OwsP0meZZt7ChJbMl6U9N+7557q2r815f/fPvVF/u/78QP3/9+8cvVm7fXF9/Yhb++8tX46is/WVhas26bDZsmLvCqm4d5mjfzbr6ZD/NpLgsuB3eFRVo0i26xWQyLaSFLLqdbcmpaNstuuVkOy2kpa1xubi2s8VubtW5tszasTWva31F362E9rfOuuvXN+rA+rcs2Lm9uW9iWtjXbeNebbcO2aZtscHm4jbCRNpqNboNPNWxMG7LJ5ek2w2babDa7zc0m... |
704,854 | Stepping Numbers | A number is called a stepping number if all adjacent digits have an absolute difference of 1, e.g. '321' is a Stepping Number while 421 is not. Given two integers nand m, find the count of all the stepping numbers in the range [n, m].Example 1:
Examples:
Input:
n = 0, m = 21
Output:
13
Explanation:
Stepping no's are... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int steppingNumbers(int n, int m)"
],
"initial_code": "//Initial Template for Java\n//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])throws IOExce... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"steppingNumbers(self, n, m)"
],
"initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n ob = Solution()\n N, M = map(int, input().split())\n ... | eJydk00KwjAQhV30ICHrIknaJI0nEay40C7c1C5aEETxEHpIdx7B6Y9gxZdQAwMh7TczvDdzje7PaNad5YMuqxPfl1VT8wXjMi+lEIxC5CWPGS+OVbGti93m0NTDP4nKywt9PcdsTGqimPGhGSAVgYmHSwEnVZIyCj25os2cYBS4pgZkr44HVIlB7XYsBKUFnHOtsq49EBao5tCuz5VMIkeNZYakwiI57IwOWIM6fhcdzSLde7uRdgalsy5oNUKVCMxlQPSv6r6RQdPWKSB7BdA+wu340cW/baBU+eh9emL7kQ1ZC/di1FWw9Po2fwHV... |
703,327 | Element with left side smaller and right side greater | Given an unsorted array of arr. Find the first element in an array such that all of its left elements are smaller and all right elements of its are greater than it.
Examples:
Input:
arr = [4, 2, 5, 7]
Output:
5
Explanation:
Elements on left of 5 are smaller than 5 and on right of it are greater than 5.
Input:
arr = ... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1619000649,
"func_sign": [
"public int findElement(List<Integer> arr)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n Buf... | {
"class_name": "Solution",
"created_at_timestamp": 1619000649,
"func_sign": [
"findElement(self, arr)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n import sys\n input = sys.stdin.read\n data = input().strip().split('\\n')\n t = int(data[0])\n index ... | eJy1U0EKwjAQ9KD/WHKu0k3ag75EsOpBc/ASe2ihIIqP0P+6qbEQ6KY24oZsWpaZZGeS+/SpZ5M21jv62FzEyZR1JVYgsDAIEpRIQOim1IdKH/fnunJlWZhbYcQ1AR+jCIMMZo4MKAcaDChnMJgCgktj98O0DVi2Af5vDBlIm5RNmU05JU44KnEydHjVcSLPNNge06ZbGVZXZajJXFA0M5qcY/y54DPke+WO8A0+iqDXKhWSI2CXx9bXnt0hYGv8RcHx0o+/RFHuUreeQ78Y1Csp/kvTACr00HDoPXXg7WPxAgacgXw= |
703,098 | Rotate Bits | Given an integer N and an integer D, rotate the binary representation of the integer N by D digits to the left as well as right and return the results in their decimalrepresentation after each of the rotation.Note: Integer N is stored using 16 bits. i.e. 12 will be stored as 0000000000001100.
Examples:
Input:
N = 28, D... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"ArrayList<Integer> rotate(int N, int D)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])throws IOException\n {\n S... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"rotate(self, N, D)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n\n for _ in range(t):\n n, d = input().strip().split(\" \")\n n, d = int(n), int(d)\... | eJylk7FOxDAMhhngPazMJ2QnthOzsvEESBQxwA0s5YaehIRAPAS8L0nbO8Hg3ECGqlLsz/bvP5/n3zcXZ/O5va4/d2/hedztp3AFgYZRRZIASdhA2L7uto/T9unhZT+tEfP1GjWMH8MY3jfwl0AYGQjRIZCmwpXATnqKWQt49UmXAl7tmFjA2nEAqRjjMEZWQwcinCIBOQBOhLkGmcXSGSEDqddCu16jHEIhi0C5LyGjqadDi6hLiMlBtAKr1g6i0UGws8dWxkmOIuB1n6K2Dahg9CzU+qKOgiqc8yHMtyH2fFh3bE1Ey8X6RiB/EWyl... |
701,167 | Gray to Binary equivalent | Given an integer number n, which is a decimal representation of Gray Code. Find the binary equivalent of the Gray Code & return the decimal representation of the binary equivalent.
Examples:
Input:
n = 4
Output:
7
Explanation:
Given 4, its gray code = 110.
Binary equivalent of the gray code 110 is 100.
Return 7 rep... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public static int grayToBinary(int n)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass GFG {\n\n\tpublic static void ma... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"grayToBinary(self,n)"
],
"initial_code": "# Initial Template for Python 3\n\nimport math\n\n\ndef main():\n T = int(input())\n\n while T > 0:\n n = int(input())\n ob = Solution()\n print(ob.grayToBin... | eJydVEtKxUAQdKH3CFk/ZHqmv27deQLBiAvNwk18izx4IIqH0PsaYyJEqESc1UDTVdVVPfN2+nF1djKe68vhcvNcP3b7Q19fVDU1HaXMTVfvqro97tv7vn24ezr0Uz0ntqZ7Heovu+p3H7uYrrSGkRDoDjcVLplgv7EFWfKA/PPBEKKZQwJBSFG3FJQhAiUrxuS5AIiszkVYsA8zCXKCCmcyy46dnDgEIKhRclec4kyBoixFhIcwIMDEgEwgtQGdsAcTAbLgq7z0cl2NJEJSsAZG4rdXGelWXbg/XrqVHCw2HFzDxOqInB06Mg233LS/... |
704,350 | Smallest number | Given two integers s and d. The task is to find the smallest number such that the sum of its digits is s and the number of digits in the number are d. Returna string that is the smallest possible number. If it is not possible then return -1.
Examples:
Input:
s = 9, d = 2
Output:
18
Explanation:
18 is the smallest num... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1720509346,
"func_sign": [
"public String smallestNumber(int s, int d)"
],
"initial_code": "import java.util.*;\n\nclass GFG {\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n int tc = sc.nextInt();\n\n... | {
"class_name": "Solution",
"created_at_timestamp": 1720019379,
"func_sign": [
"smallestNumber(self, s, d)"
],
"initial_code": "# Initial Template for Python 3\n\nimport sys\nimport math\ninput = sys.stdin.read\ndata = input().split()\n\nt = int(data[0])\nindex = 1\n\nfor _ in range(t):\n s = int(data[... | eJxrYJlay8IABhFlQEZ0tVJmXkFpiZKVgpJhTJ6hgqGSjoJSakVBanJJakp8fmkJQrIuJk+pVkcBXYcZLh0GIIBDm6kJTn2WYIBDnyVOB+LSYWigYITLhbj0GJkrGON2HW6L8AYFLn0GpIe5AW6rdHFpsrQkQ48RGZqAroNEFMk6TU3wpww8VpIXJApAwozkBIVPEyTRkwVwpkZosJAcKAqQGMSZKLHqUyA/b4ItJMbG2Cl6ALcwXAI= |
707,442 | Find number of closed islands | Given a binary matrix mat[][] of dimensions NxM such that 1 denotes land and 0 denotes water. Find the number of closed islands in the given matrix.An island is a 4-directional(up,right,down and left) connected part of 1's.
Examples:
Input:
N = 5, M = 8
mat[][] =
{{0, 0, 0, 0, 0, 0, 0, 1},
{0, 1, 1, 1, 1, 0, 0, 1},
... | geeksforgeeks | Hard | {
"class_name": "Solution",
"created_at_timestamp": 1620929709,
"func_sign": [
"public int closedIslands(int[][] matrix, int N, int M)"
],
"initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG\n{\n public static void main(String[] args) t... | {
"class_name": "Solution",
"created_at_timestamp": 1620929709,
"func_sign": [
"closedIslands(self, matrix, N, M)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n N, M = map(int, input().split())\n matrix = []\... | eJztWsFu1EAM5cCHjPbAqULjwNKKL0GiiAP0wGXpoZWQEIiPgC/lxontZie2n58zWSFRrZRGbboTzxvb79nJRPvj6a8/z54cft783v/z9uvm0+72/m7zumzkeie1SN2fyv68/334O573g+OQlHZRClgef9WyWss64jS8EVOM5RF7tBS79gNmWFtdcr6iS4fz5qJsbr7c3ny4u/n4/vP9XQv46nr3/Xq3+XZRIA1DkUFdVu8mD0U/6mLqEOTKpkQMmMuqhlttvsLiYma4xQkX9oIUcGK8YFkRvaD+mIisV25GkuBXWX63RbYNTOOxwU5Z... |
714,246 | Shortest XY distance in Grid | Given a N*M grid of characters 'O', 'X', and 'Y'. Find the minimumManhattandistance between aX and aY.ManhattanDistance :| row_index_x - row_index_y | + | column_index_x - column_index_y |
Examples:
Input:
N = 4, M = 4
grid = {{X, O, O, O}
{O, Y, O, Y}
{X, X, O, O}
{O, Y, O, O}}
Output:
1
Explanation:
{{X, O, O, O}
... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1678795965,
"func_sign": [
"static int shortestXYDist(ArrayList<ArrayList<Character>> grid, int N,\n int M)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1678795965,
"func_sign": [
"shortestXYDist(self, grid, N, M)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N, M = map(int, input().split())\n grid = []\n ... | eJzVVktuwjAQ7YJNbzHyGqE4bgD1Emxt1RWLNotuXBZBqlSBeoj2YN1xHAJ2rPgzTkIqRBMp8mfmzfh5nuOvyc/h/u788N+68fRJ3tRmW5FHIFSqAgqpOKz0K5VpgGiaXI8K16AeJVMg5cemfKnK1/X7tjKYuVR7qchuCm6gOcy1Mw9CtTt2xpoJfyYdnyHxaQY0ay01hpoc9NNsWwaonZgRyj1L0QsTYeEBYWEJSx+GB7gOzdHIQX4IRnTv0pkXSOYLWLgQ3KPTC9B0RTS8U1bB7EBSKdQfjjjRrHlmWcpfXO6fQ34qbC1ZDCbla0ob... |
703,172 | Length of the longest substring | Given a string S, find the length of the longest substring without repeating characters.
Examples:
Input:
S = "geeksforgeeks"
Output:
7
Explanation:
Longest substring is
"eksforg".
Input:
S = "abdefgabef"
Output:
6
Explanation:
Longest substring are
"abdefg" , "bdefga" and "defgab".
Expected Time Complexity:
O(... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int longestUniqueSubsttr(String S)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])throws IOException\n {\n Buffer... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"longestUniqueSubsttr(self, S)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n s = input().strip()\n\n ob = Solution()\n pr... | eJy9VMlOwzAU5ID4C6TI4lgh0iW03Nj3fSsQhOzEJKGt49pOnRaB+hHlf7HogU0vJRFg5WDLmXmTN5M3nH6Zm5l6W81Zs7l5RBHjiUJLFrJdhlHJQjTl1FPUv4sT9X717DL0VLK+vE88n1LfIxCwBgPNQwgAqwAwQkAIKBFDiDKA4Fq3qM6prB2zgEolEyKViFigIxUalKCcYmXOXogFNlxCAsSNrBbfB2H00Gp3WMy7Qqqkp9P+APosB2DqaipUP4lijqVvGA3hIPV6hHXGN3n5YGXLK6tr6xubW9s7u3v7B4dHxyenZ+cXl82r6wW7... |
710,136 | Maximum trains for which stoppage can be provided | Youare given n-platform and two main running railway tracks for both directions. Trains that need to stop at your station must occupy one platform for their stoppage and the trains which need not stop at your station will run away through either of the main track without stopping. Now, each train has three values first... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1655116246,
"func_sign": [
"int maxStop(int n, int m, ArrayList<ArrayList<Integer>> trains)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nimport java.lang.*;\n\nclass GFG {\n public static void main(String... | {
"class_name": "Solution",
"created_at_timestamp": 1647417203,
"func_sign": [
"maxStop(self, n, m, trains)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n for _ in range(int(input())):\n n, m = map(int, input().split())\n trains = []\n for i ... | eJzFlLFOwzAQhhmQeI2T5wrZ57uU9hHYuiEBYoAMLKVDKiFVRTwEfV/sS+y0VS8RSSQy2JYTf//vP2d/Xx9WN1fyPNyHwePOvK8328oswbintYPQWHA29mYGpvzclK9V+fbysa3az77Cy/0MTtciYFzLcSl3I1BF+IwgKCKwh+QVkoei3cgCUHrHgFy79DZKhddk44RnII4zigypMtTKhBaFhonvha+717F8jnUJm+xjwg9xfYQPAUsmWSanlLeh4FnFz1X3dXnVglknJC/h9/2FuSIYa6RH0bZbxJMkXSoElEHes/SkHwKreCG4axaL... |
701,222 | Floor in a Sorted Array | Given a sorted array arr[] of size n without duplicates, and given a value x. Floor of x is defined as the largest element k in arr[] such that k is smaller than or equal to x. Find the index of k(0-based indexing).
Examples:
Input:
n = 7, x = 0 arr[] = {1,2,8,10,11,12,19}
Output:
-1
Explanation:
No element less tha... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1730214554,
"func_sign": [
"static int findFloor(int[] arr, int k)"
],
"initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.util.*;\nimport java.util.HashMap;\n\n//Position this line where user code will be pasted.\npublic class ... | {
"class_name": "Solution",
"created_at_timestamp": 1730214554,
"func_sign": [
"findFloor(self,arr,k)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n arr = list(map(int, input().strip().split()))\n k = int(input()... | eJztms2OJUcRRlnwIKVeWsaqyP/kSZBoiwXMgk3jxViyZCHxEPCY7HgAzom6CJD6GgZPm9HojianqvNGREbEF395p//087/87Yuf5Z9f/ZWXX3//9PuXb759//TL4ymeX+rRj3nsI+KIesQ8Yh+lHmUfNY46jxZHq0ebR4dyHyOOMY8Zx6zH3Meqx9rHhuuE/0TA6bvieC+8V+X6ZK+xOj93fh58jqSYHsr+Yn+7+Fl5GzXQqagLckpRLd6RU9CpdBf7yCmDPVQqk5+RU5b616OiS0VGRZeKZVWL0KU2FwZiUsWmih4VPSp6VHgrJlV0... |
701,420 | Egg Dropping Puzzle | You are given N identical eggs and you have access to a K-floored building from1toK.
Examples:
Input:
N
= 1
, K
= 2
Output:
2
Explanation:
1. Drop the egg from floor 1. If it
breaks, we know that f = 0.
2. Otherwise, drop the egg from floor 2.
If it breaks, we know that f = 1.
3. If it does not break, then we... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1731014139,
"func_sign": [
"static int eggDrop(int n, int k)"
],
"initial_code": "import java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass GfG {\n\n public static void main(String[] args) throws IOException {\n\n // Reading input us... | {
"class_name": "Solution",
"created_at_timestamp": 1731014139,
"func_sign": [
"eggDrop(self,n, k)"
],
"initial_code": "# Initial Template for Python 3\nimport atexit\nimport io\nimport sys\n\n# Contributed by : gokul\n\nif __name__ == '__main__':\n test_cases = int(input().strip())\n for cases in r... | eJydU7sOwjAMZOiHVJkrZEeEIr4EiSAG6MASOhQJCYH4CPhFNv6B1lBSHldIM0QZcue7s32MzteoJ2dyKR/TnVq5fFOocazYOiayzpBKYpVt82xRZMv5elM8PgytO1in9kn8itIVqrwAbNQGYwBiADKdSnEFY2gMKjQlKjWhxcQX1JgCWGq6hxhcjDvlIeE34oRlDSAgTQ3NrcqxYS+frCUhAhwD5P67kr/tCRYx19uA45UfuC1+gjAFqt+wpcWW/rnVKOj7PPqV80TBY/MRzHvQgS4lpmf7oLO6/bNT/wZvQ4R0 |
704,114 | Minimum Points To Reach Destination | Given a m*n grid with each cell consisting of a positive, negative, or zero integer. We can move across a cell only if we have positive points. Whenever we pass through a cell, points in that cell are added to our overall points, the task is to find minimum initial points to reach cell (m-1, n-1) from (0, 0) by followi... | geeksforgeeks | Hard | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int minPoints(int points[][], int m, int n)"
],
"initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.util.*;\n\nclass GfG {\n public static void main(String args[]) {\n Scanner sc = ne... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"minPoints(self, m, n, points)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n m, n = input().split()\n m, n = int(m), int(n)\n ... | eJztWsFu2zAM3WEfQvhcDaIky+6+ZMA87LDlsIvXQwoMKAbsI7b/HR8pO1lqZ0ubtSmgpoltiXx8fKSi1M2P17/umlf6824rJ+/vmi/jze22eUsNDyN7Yj+MTo6upUhBHolcTy5TS2KQZdBdE5PrZEps5MiUhlGsWEZkAr5BrDM5DA4jLlwESqcekXr4xmGM8IVhwFRCCIkk8VsxiOaWYcvgMoydxc7gBATS+L049FQugkIqyYDQyahHUkwxQDqSKLw1hZ6QEyvn5oqazbebzaft5vPHr7fbSRhJovl+RX9qFTwFjxwcYnp5OAimaQRE... |
710,026 | Largest rectangular sub-matrix whose sum is 0 | Given a matrixmat[][] of sizeNxM.The task is tofind the largest rectangular sub-matrix by areawhose sum is 0.
Examples:
Input:
N = 3, M = 3
mat[][] = 1, 2, 3
-3,-2,-1
1, 7, 5
Output:
1, 2, 3
-3,-2,-1
Explanation:
This is the largest sub-matrix,
whose sum is 0.
Input:
N = 4, M = 4
mat[][] = 9, 7, 16, 5
1,... | geeksforgeeks | Hard | {
"class_name": "Solution",
"created_at_timestamp": 1651219902,
"func_sign": [
"public static ArrayList<ArrayList<Integer>> sumZeroMatrix(int[][] a)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\nclass IntArray\n{\n public static int[] input(BufferedReader br, int n) throws IOException\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1651219902,
"func_sign": [
"sumZeroMatrix(self, a : List[List[int]]) -> List[List[int]]"
],
"initial_code": "class IntArray:\n def __init__(self) -> None:\n pass\n\n def Input(self, n):\n arr = [int(i) for i in input().strip().split()... | eJztWU2P0zAQ5cAPecp5jfLddvkjSARxgB64hD10JSTEih8B/5eZiZM6zkzIFq12Vbxpk9Seee/N2HXj2Z+vf7/NXsnfu5pu3n/PvvR396fsFlnR9Q0aOQ1H17sGwavrixyO3tOFLMKPfAn8sxtkx293x0+n4+ePX+9PnmfqR0yAJQMUCmp76Prsxw3m6lu0DCA2bBvdvKQ+IzW2A9bQnqlTHYQdduSGEhVqGuKWP7odXCtDXMNVcCUhsGVLBjUZlih4mKWjEqNGHLYiFQgOK7UBkIYz16PJmYvRMUIlRoL22Hf9Ae6APdweBMLEjqYu... |
700,405 | Print matrix in diagonal pattern | Given a square matrix mat[][] of n*n size, the task is to determine the diagonal pattern which is a linear arrangement of the elements of the matrix as depicted in the following example:
Examples:
Input:
n = 3
mat[][] = {{1, 2, 3},
{4, 5, 6},
{7, 8, 9}}
Output:
{
1, 2, 4, 7, 5, 3, 6, 8, 9}
Explanation:
Starting f... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1617209242,
"func_sign": [
"public int[] matrixDiagonally(int[][] mat)"
],
"initial_code": "import java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG\n{\n public static void main(String[] args) throws IOException\n {\n BufferedR... | {
"class_name": "Solution",
"created_at_timestamp": 1617209242,
"func_sign": [
"matrixDiagonally(self,mat)"
],
"initial_code": "# Driver Program\nif __name__ == '__main__':\n t = int(input())\n for i in range(t):\n n = list(map(int, input().strip().split()))\n arr = list(map(int, input... | eJydVN1OgzAU9sL4HF+43jGc0sLmk5iI8UK58KbuApIlRuND6Pt62gKRsIOwsZGVfn8tX/p1/dPdXMXPvZc/D+/Zqz92bXaHjGsfvnme7ZA1p2Pz3DYvT29dO8znOWr/WfvsY4cpr6g9hWlyOXLILQ7CLY5IFx1pkZkY8VlP0xytJIVBAQuHEhX2OAgdzGADLsAW7MClthghO6GUUaKK1ERikQoSgay5u9qHeCADKkBWVgAqQRVoDzqE5PKTeREi0SURJlEkkSQWFAuMBWcEZ4KO4IzgjFXyJjuXlMvBuOpdXFKK6iZmsClGkewGi2hr... |
707,049 | IPL 2021 - Match Day 4 | Due to the rise of covid-19 cases in India, this year BCCI decided to organize knock-out matches in IPL rather than a league.
Examples:
Input:
N = 4
arr[] = {4, 8, 12, 16}
Output:
8
Explanation:
Pair (8, 12) has the
Maximum
AND
Value
8.
Input:
N = 4
arr[] = {4, 8, 16, 2}
Output:
0
Explanation:
Maximum
AND
V... | geeksforgeeks | Medium | {
"class_name": "AND",
"created_at_timestamp": 1618213780,
"func_sign": [
"public static int maxAND(int arr[], int n)"
],
"initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass BitWise {\n \n\tpublic static v... | {
"class_name": "Solution",
"created_at_timestamp": 1618213780,
"func_sign": [
"maxAND(self, arr,n)"
],
"initial_code": "# Initial Template for Python 3\n\nimport math\n\n\ndef main():\n T = int(input())\n\n while T > 0:\n n = int(input())\n arr = [int(x) for x in input().strip().split... | eJytlM1KxDAUhV3oe1yyHiT3Jz+dR3DnTjDiQrtwU2fRgQFx8CH0fU0TyghjUlLtIhRyz+Xce7724/Lr9uoiPXc38eX+Tb0Mu/2otqAwDBQGBFQbUP1h1z+N/fPj63483R/DoN43cCbSoAsiXRBxEjXLTDSoiSEeAqTFg+jOgseOGjtJ9EDOOrDGsAFk1A6BLKFwaQGppryFqZ+H6ewKHVJF3ZBPhmw2RNmQNM6WYow6J56tuMY8UzR/0MdB0LIXyONIh4byUCu2kjnJsfwbLbqMy1SwTIw1PDMzCRa4SarfmpbmqdClObkvAVYhYqYz... |
705,605 | Break Numbers[Duplicate problem] | Given a large number N, write a program to count the ways tobreak it into threewhole numbers such that they sum up to the original number.
Examples:
Input:
N = 3
Output:
10
Explanation:
The ways are
0 + 0 + 3 = 3
0 + 3 + 0 = 3
3 + 0 + 0 = 3
0 + 1 + 2 = 3
0 + 2 + 1 = 3
1 + 0 + 2 = 3
1 + 2 + 0 = 3
2 + 0 + 1 = 3
2 + 1... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static long countWays(long N)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG{\n public static void main(String args[])throws IOException\n {\n BufferedReade... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"countWays(self, N)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n\n for _ in range(t):\n N = int(input())\n\n ob = Solution()\n print(ob.count... | eJylk0EKwjAQRV3oPUrWRZLUWOtJBCsutAs3sYsWBFE8hJ7NnWcxtImtpb8TNGQRSPL+zPyZ2/jxmoyqtXqaw/rMDjovC7YMmEi12SwMWHbKs12R7bfHsrCXUaqv5vISBp0f3C34VdkH4nMALAkRc/AjcYsU56qJsxelyDyEtG9iNZxHhBFIXQwX0JQOic2wmIJiuNCo0sLH5NphFKmwGBtBqjEtXlCGezjeWA6r/t2/HnByDDpIeipcU3GEVpZa7XaIdLdWHQtDTkD2HKcvcQN3afU8/8/0Y/dX/1fdBkYrEwZbe5EJUdtTD7MHBaWb... |
704,426 | Sum of Digit Modified | Given a number N. Check whether it is a magic number or not.
Note:- A number is said to be a magic number, if the sum of its digits are calculated till a single digit recursively by adding the sum of the digits after every addition andthe single digit comes out to be 1.
Examples:
Input:
N = 1234
Output:
1
Explanation... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int isMagic(int N)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader read =\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"isMagic(self,N)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n ob = Solution()\n print(ob.isMagic(N))\... | eJxrYJmazcIABhEpQEZ0tVJmXkFpiZKVgpJhTJ4lDCjpKCilVhSkJpekpsTnl5ZAlRjE5NXF5CnV6iig6jM0gAEcGg1xaLS0MDczNTE2MiTVQiNjE1MzcwuSHQoDJOozhQES9VlAAYnBYmgAhaQ6ExSUuOIAlyYy4xzqMwpca0goNggFDzkeJTVEjUgOUpyZAHfQIwciLhfizEJIZsABuebhzsFYYoG4sImdogcAzShWJw== |
703,550 | Tom and String | Given a list S consistingof stringsseparated by a space.Hash the list using the hash rule and a long string Xgiven belowand return the hash value.String X: "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ".Hash Rule:Hash is the summation of all the character values in the input:(currentIndex + (position ... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static long hashString(String s)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n//Position this line where user code will be pasted.\nclass GFG {\n public static void main(String args[]) throws IOException {\n... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"hashString(self, S)"
],
"initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n s = input()\n ob = Solution()\n print(ob.hashString(s))\... | eJy1VNtOwkAQNcbE+BeTPhOzu93efKNcvYsXLHWNaUsBbwsqaMFo/Aj9XzeFEI0MASJNNjt9mDkzZ87Zj7WvjfWV9PNWVXDxql3LTq+rbYGmCxlkKfg1T0gSUHCjHCQeFdL3fRio4w98IbUMaHHSiaNuXL9q97qjZO6YQr4LaZlGelNu2GmgvWXgBwgTMutSBrm8zqFQNFQWDVgIesTrYMRmA6lPmUnSeiZlk+qqNgllOjdMy3YgCKN63Gi2rm9u7+5lu/Pw+NTtPb8k/QFk3Vy+UCyVt3d29/YPDo8qxyenZ9Vzr4bPZlmTZ+FCJtCH... |
705,651 | Find the string in grid | Given a 2D gridof n*m of characters and a word, find all occurrences of given word in grid. A word can be matched in all 8 directions at any point. Word is said to be found in a direction if all characters match in this direction (not in zig-zag form). The 8 directions are, horizontally left, horizontally right, vertic... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int[][] searchWord(char[][] grid, String word)"
],
"initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG\n{\n public static void main(String[] args) th... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"searchWord(self, grid, word)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n, m = input().split()\n n = int(n)\n m = int... | eJzlVttu00AQ5YF3fuHIzwVlc9lYfAkSi1AdO7EN3SRt0iYgUD8C/pfZM5Hl1HGVGy0XjzxO5visZ2dnZ+f+5c/7Vy94vVvLj/dfo8LPlovoLSLj/AAD5y+RYIQUmfNjTJCjQOn8J3zGFTymzs8wxzVusHB+iVvcYYW10JJRGl0gylazbLTI0o/T5WIz8msZ+rvz0bcLbH/PwobvVeJ8gkqcH6ES51NU4nyGSoKXlagb2bjFkQ46cL6DLnWf2lLH1CbAOz0dYuj8F5npSGacSByunJ/L1DOJxAJrLJ0vMMVMZnEjLoojIXIlQtiEFuay... |
702,868 | At least two greater elements | Given an array arr of distinct elements, the task is to return an array of all elements except the two greatest elements in sorted order.
Examples:
Input:
arr[] = [2, 8, 7, 1, 5]
Output:
[1, 2, 5]
Explanation:
Here we return an array contains 1 , 2, 5 and we leave two greatest elements 7 & 8.
Input:
arr[] = [7, -2,... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public long[] findElements(long arr[])"
],
"initial_code": "// Initial Template for Java\n\n// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass GFG {\n public static void mai... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"findElements(self,arr)"
],
"initial_code": "# Initial Template for Python 3\ndef main():\n T = int(input())\n\n while T > 0:\n arr = [int(x) for x in input().strip().split()]\n ob = Solution()\n prin... | eJy1VUtOAzEMZYHENaxZd9B48pkZToJEEQvogk1h0UpICMQh4IrsuAMviVO103FoVRHJctX4vdjOc+bj/Ovn4iyu62/8uHmtHpfP61V1RRXPl9zERUNcVGef/2+IqSVDllw1o2rx8ry4Xy0e7p7WKyHZhGbsFmS+fJ8vq7cZjQ+lgXrqyJNDmEE4K+wbKsR21CuELvIEpsAFtgIfxwgTWa2aYEMtzMAszME8rIP1oVuwULZ2SBmuHLrXyOR78Z14L96Jt+KN+Fa81oFTjym0DGTgAQXQAAKDrJCQmsvAcdvEUBdhAGu3zDFrFrnGfEgS... |
706,276 | Binary Search in forest | There are n trees in a forest. The heights of the trees is stored in array tree[],where tree[i]denotes the height of thei**thtree in theforest. If thei**thtree is cut at a height H, then thewood collected is tree[i] - H, providedtree[i] > H. If the total woods that needs to be collected is exactly equal tok,find the he... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1618941710,
"func_sign": [
"static int find_height(int tree[], int n, int k)"
],
"initial_code": "import java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\nclass GfG\n{\n public static void main (String[] args)\n\t{\n Scanner in = new Scan... | {
"class_name": "Solution",
"created_at_timestamp": 1618941710,
"func_sign": [
"find_height(self,tree,n,k)"
],
"initial_code": "t = int(input())\n\nfor _ in range(t):\n n = int(input())\n tree = [int(x) for x in input().strip().split()]\n k = int(input())\n\n ob = Solution()\n print(ob.find... | eJzNVUFOwzAQ5MCNT1g5F2R7d5OYlyARxAF64BI4tBISAvEI+Bk3PsOsbdoe6qhR00KlrRJn5Jldz67fTz+/z07i7+oLD9cv1UP/tFxUl6ZyXe+shrUmhIBoEQ2iRgiCEYTwCKBFrK1mppo/P83vFvP728flIu91js9vXV+9zswWBuMNGTZiatMYkJi4KoW9ZGArKDA7RNeXhMaPZaVaizF/Xc/loqBeJS6JXMYjCMFZeo1oEK0eyYpHkU6hTrFOwS7m0ZS5yZfK6OOJSNxc94kivCQhJEkMskq1lCSqliQMjFFcK0lgkHQoo30hsdrg... |
713,969 | Unique Paths in a Grid | You are given a matrix grid ofn x m size consisting of values 0 and 1. A value of 1 means that you can enter that cell and 0 implies that entry to that cell is not allowed.
Examples:
Input:
n = 3, m = 3
grid[][] = {{1, 1, 1};
{1, 0, 1};
{1, 1, 1}}
Output:
2
Explanation:
1
1 1
1
0 1
1 1 1
T... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1675768528,
"func_sign": [
"static int uniquePaths(int n, int m, int[][] grid)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader read =\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1675768528,
"func_sign": [
"uniquePaths(self, n, m, grid)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n n, m = map(int, input().split())\n\n grid = []\n ... | eJxrYJm6gZUBDCJWAhnR1UqZeQWlJUpWCkqGMXmGCiAiJk9JR0EptaIgNbkkNSU+v7QEoaIOKFmro4BFmwFObQY4tBkpGIH0AqUNFHBbSkC3IX7duJyM0G2IR7cRTt3GYI0Q/eTYbwz3O9mOMIY4wgAagFBjyAhJUwVTqFaEjwwgvoKIGUBC2QChAK4Wh1UmhKxCdjDMfCgHGqQYCnBYZYHNKpAhONSjq6SvqwwMiHMWhdFiitv/uKMGM1sQ7wBwMJLgClxpEVYCGcbEQIxEz+d4zMSa14gPbyMF8ksUUMySYhGpxUfsFD0AjjikZA== |
704,156 | Minimum Time | Youare given time for insertion, deletion and copying, the task is to calculate the minimum time to write N characters on the screen using these operations. Each time youcan insert a character, delete the last character and copy and paste all written characters i.e. after copy operation count of total written character... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int minTimeForWritingChars(int N, int I, int D, int C)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nclass GfG\n{\n public static void main(String args[])\n {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"minTimeForWritingChars(self, N, I, D, C)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n N, I, D, C = input().split()\n N, I, D, ... | eJyVlE1qAzEMhbvIQYTXoejHtjw9SSEpXbSz6CbNYgKBUugRskjJdeNxEmhAmqHyZhb+ePJ70vwsfk+Lh1bPh/qx+gofm+1uCE8QaL0hbAUMAhyWEPr9tn8b+vfXz91wvZbqvfC9hHsyXcAEEcQBC1pg1woIqNIOSWhqjgw2El3Q1CSWmDJofWV0yI7NZovmFKs9ybcnWuCop2V8I0Pxmi2mZpMUaMchNVngiDHVVtU3ls1uCRkFIdcws0eK2exNc0qU0Ra9pvn/OO9GiDyPbHf/JuqhombDt2BoIhlCmYlGPJsyd7OoekOI2R78uqM6... |
703,694 | Minimum product pair | Given an array of positive integers. The task is to print the minimum product of any two numbers of the given array.
Examples:
Input:
arr[] = [2, 7, 3, 4]
Output:
6
Explanation :
The minimum product of any two numbers will be 2 * 3 = 6.
Input:
arr[] = [198, 76, 544, 123, 154, 675]
Output :
9348
Explanation :
Th... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1617638860,
"func_sign": [
"public long printMinimumProduct(int arr[])"
],
"initial_code": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int t = Integ... | {
"class_name": "Solution",
"created_at_timestamp": 1617638860,
"func_sign": [
"printMinimumProduct(self, a)"
],
"initial_code": "# Initial Template for Python 3\ndef main():\n T = int(input())\n\n while T > 0:\n # Convert input to list of integers\n a = list(map(int, input().strip().s... | eJylVE1LxDAQ9SCevXl95LzITD4bf4ngigddYS91D10QRPBH6P+1zTSHQtM27BTyApl5M5M36c/1393NVbLH237z9KWO7encqQco3rcaRu2gDp+nw2t3eHv5OHfjod+36nuHqTuDC+485x6TgSlZIVKcxKWQczGeF0IJmmAIluAInhAIDSHSwFng06Uy+ruChYNHQIOhLXBfnAYbsAU7sAcHcAOOfeIS/3ylyTDeWFobgSDgBZyAFTACWqCkTSIzA3+YT45NX43yuR/OHenck8ld2dyXq7koJ7wJWEALGAEr4AS8QBBoBGIpoUQWx2m4... |
705,338 | Sequence Fun | You have a sequence 2,5,16,65,........Given an integer n as input.You have to find the value at the nth position in the sequence.
Examples:
Input:
n = 4
Output:
65
Input:
n = 10
Output:
9864101
Constraints:
1 <= n <= 10**4 | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int NthTerm(int n)"
],
"initial_code": "import java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG\n{\n public static void main(String[] args) throws IOException\n {\n BufferedReader br = new Bu... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"NthTerm(self, n)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n = int(input())\n ob = Solution()\n ans = ob.NthTerm(n)\... | eJytVctOw0AM5IDEb1Q5V2jttdc2X4JEEAfogUvooZWQEIiPgF/kxj/gJJVIWjaPlj1UUdeemXjGyvv55/fFWXOuv/zh5qV4rNbbTXG1KKCsoFguitXzenW/WT3cPW03uyssq7eyKl6Xi7364CfTYwpBAOivVscb6faKIYDYALD3j8IAJVJW02FE9ms/O7gOvHAWHZQgOGhPbJ8SjZKBoebeouFomWr+DFOCxCRM1gPv8B+CuxRAZyBOUlZqAWqVkjIMLiGycnQsRDbQGH0kHBXM/0/+aMTGMWb8RB4ZVjKSkBLKyFC4GYoXNTOJ9Q+1... |
702,875 | Drive the car | You are a car driver tasked with driving on a track divided into sub-tracks. The car can travel "k" kilometers on each sub-track. If the car can't cover a sub-track, you can add petrol, with each unit increasing the car's range by one kilometer. Return the minimum units of petrol needed for the car to cover all sub-tra... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int required(int[] arr, int k)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass Main {\n public static void main(String args[]) throws IOException {\n BufferedReader read = new BufferedRead... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"required(self, arr, k)"
],
"initial_code": "def main():\n T = int(input())\n\n while T > 0:\n arr = list(map(int, input().strip().split()))\n d = int(input().strip())\n ob = Solution()\n print... | eJxrYJmaycoABhFJQEZ0tVJmXkFpiZKVgpJhTB4IKekoKKVWFKQml6SmxOeXlkBldYFySrU6CmgaDMBAgQAdk2cKpnGYbQpVhMV8BSiMyTMizWEIq3H5yBIMsGmGuEfBBKxAAcwzJOAF/KED8wPESlKMgOhQwEPBrSEtfMjUBg9UMjQbKRhDg8IId6wY4bYWEgeG5DsAkSpxplMD/LFsYIA7rVIhUlDTC1kJxoi4LGeExyPEBBMF4YSWhnDlTpz6IcmIgnSEEcD4nIAv90AovFEcO0UPAGE/f10= |
703,767 | Factor OR Multiple | Given an array A comprising of N non-zero, positive integers and an integer X, find the bitwiseOR of all such elements in the array that are a multiple of X. The result of OR operation should be in decimal form.If no multiple of X is found, the answer should be 0.
Examples:
Input:
N =
4 ,
X =
2
A =
{3 , 4 , 3 , 9}... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int factorOrMultiple(int N,int X,int A[])"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"factorOrMultiple(self, N , X ,A)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N, X = map(int, input().split())\n\n A = list(ma... | eJzFlbtuFEEURAkI+IzSxBa6j7798JcgeRABbEDA4GAtWUJY/gjzv65u2zyC5jGy2E1mpdHUrXuqZvr25bfjqxfj9+YT/1x8WT5ul1fH5RyLrpsKYt0CvGrABBZwgQeSIAVC1m05w3K4vjy8Px4+vPt8dXx8Ovu63fDu1zP8qplRKJxgFaZDypDav+tUpHVLqNAMN+QE7ZKREWpTORWTiaAatF8UZnBHSohApt+CWtEab5MDTavPB1jETD/ANalClwWeB8CE7CiGqmgyZgg30sI5mXNix5yK/LAM56QRVx6MK6fNMdtEjaErbWuDU6Cg... |
712,224 | Outermost Parentheses | A valid parentheses string is either empty"","(" + X+ ")", or X+ Y, where Xand Yare valid parentheses strings, and+represents string concatenation.
Examples:
Input:
s = "(()())(())"
Output:
"()()()"
Explanation:
The input string is "(()())(())", with primitive decomposition "(()())" + "(())".
After removing outer par... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1664428826,
"func_sign": [
"public static String removeOuter(String s)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n BufferedReader br =\n new Buffer... | {
"class_name": "Solution",
"created_at_timestamp": 1665577777,
"func_sign": [
"removeOuter(self, S)"
],
"initial_code": "# Initial Template for Python 3\n# Position this line where user code will be pasted.\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n s = input()\n ... | eJy1VEEKwjAQ9CD4jZJTForQqy8RrHjQHgSJBVsQRPER+l+TJq1J293EUHMIDdnZnZls9zl/XxazZq1P8mNzY0dR1hVbJSzLBYdcsDRhxbUs9lVx2J3rytzm4iHv7mnSQ3DAMSodgpIwAtckHUdCFEdPPaAqKrhEqxB/piZWbZ6MJgK42cFUIT3hLQlo4/EK1gJnERUwDP4WWm6rWuvgdJWOu/7iRP4BGffsVeLCSC24nIh2w2l7vMF4c+oVRrrJ2wK/tltG2mYmx1TuuXL6jlrjwxJiKATqoeVoAeoIA3mZ1jcBUdsi27Oo6Rb0t/hG... |
704,749 | 12 hour clock subtraction | Given two positive integersnum1andnum2, subtract num2 from num1 on a12 hour clock rather than a number line.Note: Assume the Clock starts from 0 hour to 11 hours.
Examples:
Input:
num1 =
7,
num2 =
5
Output:
2
Explanation:
7-5 = 2. The time in a 12 hour clock is 2.
Input:
num1 =
5,
num2 =
7
Output:
10
Explanatio... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int subClock(int num1, int num2)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n Buffer... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"subClock(self, num1, num2)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n num1, num2 = map(int, input().split())\n\n ob = Soluti... | eJy9VL1OwzAQZkDiNU6ZK2T7fP7hSZAIYoAOLKFDKyEhEA8BKxvvyZ2dwZDYDajFw8U9p9/PnS+vp++fZydpXX7w5uqpux82u213AZ3tB01gQj8YBMc/lIJI/UAOLHUr6NaPm/Xtdn1387Dbjv/Ruh9e+JUijqnueQUFOAoe41LgY48EjK76QYHWNWhVws2CMqE2oE0/xAghJMmsOUbJI6tmFz5EcGQrJDMcWMQZPmEgka45gifeGclpI8lIiml5g5IiVaENCd2lGIro5lhtcmMJyKJhjTF4B459MbN1gXmQvFjmBYZX0ysWVmmOjjUI... |
700,133 | Check for Binary | Given a non-empty sequence of characters str, return true if sequence is Binary, else return false
Examples:
Input:
str = 101
Output:
1
Explanation:
Since string contains only 0 and 1, output is 1.
Input:
str = 75
Output:
0
Explanation:
Since string contains digits other than 0 and 1, output is 0.
Constraints:
... | geeksforgeeks | Easy | {
"class_name": "GfG",
"created_at_timestamp": 1617123105,
"func_sign": [
"boolean isBinary(String str)"
],
"initial_code": "import java.util.*;\nclass checkBinary\n{\n\tpublic static void main(String args[])\n\t{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint T = sc.nextInt();\n\t\tsc.nextLine();\n\t... | {
"class_name": null,
"created_at_timestamp": 1617123105,
"func_sign": [
"isBinary(str)"
],
"initial_code": "# Your code goes here\nif __name__ == '__main__':\n t = int(input())\n for i in range(t):\n str = input().strip()\n if isBinary(str):\n print(1)\n else:\n ... | eJxrYJlqy8oABhFmQEZ0tVJmXkFpiZKVgpJhTJ5BTJ6SjoJSakVBanJJakp8fmkJQrIOKFmro4CqwxAOSNZqAAek22oAg2RohQLSHWxoZGxiamZuYYnbVgMcWkm2KzEpOSU1LT0jM4tkuwwNDYzw+A6XNgMsgNzkgMs0MoxDDXa8PsOZ0GJi0CKe5MCBRkcKMD6QQpj0IEak3ZgYcOolJ5BR/YOWkyjxXkZmRgbp6Q3JV9TxEjBoqBJJWNMOLgeTEK2xU/QA9y+a8w== |
702,837 | Count the triplets | Example 1:
Examples:
Input:
N = 4
arr[] = {1, 5, 3, 2}
Output:
2
Explanation:
There are 2 triplets:
1 + 2 = 3 and 3 +2 = 5
Input:
N = 3
arr[] = {2, 3, 4}
Output:
0
Explanation:
No such triplet exits
Your Task:
You don't need to read input or print anything. Your task is to complete the function
countTriplet()
w... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1729253195,
"func_sign": [
"int countTriplet(int arr[])"
],
"initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass GFG {\n public stat... | {
"class_name": "Solution",
"created_at_timestamp": 1729253195,
"func_sign": [
"countTriplet(self, arr)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input())\n while t > 0:\n arr = list(map(int, input().split()))\n ob = Solution()\n ... | eJytVMtKBDEQ9CB+gzeLOS/SnXf8EsEVD7oHL+MedkEQxY/Q/7U7EfYByeyIM0wnzJCqSlVPPs+/ry7OynV7KZO7t+F5XG83ww0GXo5MMARLcARPCIRISIRMYKJhgWH1ul49blZPDy/bze86Q8vxYzkO7wsco8ky5AyDnGCRIxxygG8AsWsDqR6VVYSIMFWm0lSt6lPhswUqpPH1YeNho0eQMcnI+jLqB98E7goWVXJpSVqilqDFa3FarBajhRsMTWtRKCpHIakslabyVKLKVKmyadCkjkEs8VkJTqxBhLC0zAi99Pj4nrthY0VCiMLP... |
704,948 | Sum Palindrome | Given a number, reverse it and add it to itself unless it becomes a palindrome or return -1 if the number of iterations becomes more than 5. Return that palindrome number if it becomes a palindrome else returns -1.Examples :
Examples:
Input:
n = 23
Output:
55
Explanation:
reverse(23) = 32,then 32+23 = 55 which is a pa... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static long isSumPalindrome(long n)"
],
"initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedRea... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"isSumPalindrome(self, n)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n n = int(input())\n ob = Solution()\n print(ob.isS... | eJy1VctOwzAQ5MCBz4hypaD41Th8CRJBHKAHLqaHVkJCWHwE/C9je+OmwhsCgVUlW7FnZ+yddd9OP+TZSYzrc0xuXupHt93v6quqFr3rEPWqqjfP2839bvNw97Tf0WpY6p3vXf26qkYo2TvRACobySDjso87SglUpO2dRfSuRfAKIj5t9GlvKSPohJSCk4Ml5iCdbdfI364NK0EpUqGhQpfymMCu9JBt3VoAlDaYI7FmMhtEzDaiOJrSBOrL8gNtE25aIHDZCNAiIBXB1oaKk1B+APoB6xOcYUyywoVhmwrCDM6Lg9qu+c5HhwvMZz98... |
714,002 | Count Binary Strings With No Consecutive 1s | Given an integer N. Your task is to find the number of binary strings of length N having no consecutive 1s.As the number can be large, return the answer modulo10^9+7.
Examples:
Input:
N = 3
Output:
5
Explanation:
All the binary strings of length 3 having
no consecutive 1s are "000", "001", "101",
"100" and "010".
In... | geeksforgeeks | Hard | {
"class_name": "Solution",
"created_at_timestamp": 1676008969,
"func_sign": [
"public int countStrings(long N)"
],
"initial_code": "// Initial Template for Java\n// Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\nclass GFG {\n public static void main(String[... | {
"class_name": "Solution",
"created_at_timestamp": 1676008969,
"func_sign": [
"countStrings(self, N)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n while T > 0:\n ob = Solution()\n print(ob.countStrings(int(input())))\n T... | eJxrYJm6noUBDCJWABnR1UqZeQWlJUpWCkqGMXlApKSjoJRaUZCaXJKaEp9fWgKVNIrJqwNK1uoooOowwqnDGIcOY5LtMCHZDlOcOkxx6DDDqcMChw5znDoMcTnLArfXDXFoMTTA7RVcfjHCrcfM3AyXLhNw9OOOHVyeguhDNoB0M8zAWnHHGq44AIrHxJjgSSA4w9UYqhvF4bgj1MTMyMwSr1ExkECgookQoyg1CxK0FiAyBpo2yAhobKaQagZGQomB+otweomdogcAab6DIA== |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.