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
708,502
Articulation Point - I
Given an undirected connected graphwithVvertices and adjacency listadj. You are required to find all the vertices removing which (and edges through it) disconnects the graph into 2 or more components and return it in sorted manner.Note:Indexing is zero-based i.e nodes numbering from (0 to V-1). There might be loops pre...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1629729024, "func_sign": [ "public ArrayList<Integer> articulationPoints(int V,ArrayList<ArrayList<Integer>> adj)" ], "initial_code": "// Initial Template for Java\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG\n{\n public sta...
{ "class_name": "Solution", "created_at_timestamp": 1629729097, "func_sign": [ "articulationPoints(self, V, adj)" ], "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)]\n for _ in r...
eJy1lD1OxDAQhSkQ5xilXpDHjn9CQ8cZkFhEASlosltkJSSExCHgvswbh9UuG4u4IIVlx28+vxmP/HH+dXtxpt/djUzu35qXYbsbm2tqeD0wmfXQrKjpX7f909g/P25247R9ySR77ys6DrEkg8FQF+fITnGMWSF4PrYldxhrsSwC7CzCUzhBOGrBNli2tfkE8hPQ5Mx+gA4bBZaoZmEsoFMcA8fAWbi3FEFPGDoY93Ah/1JeBmQZMYvVBqxs+FKB/FQ+PSzCgJ7YEZtsHUFMLGEs7QHnjhjeW02LPbGEcyAWAEdiQXAiFgh3qL/JKCVZ...
700,558
Anagram of String
Given two strings S1 and S2 in lowercase, the task is to make them anagram. The only allowed operation is to remove a character from any string. Find theminimum number of characters to be deleted to make both the strings anagram. Two strings are called anagram of each other if one of them can be converted into another ...
geeksforgeeks
Easy
{ "class_name": "GfG", "created_at_timestamp": 1615325282, "func_sign": [ "public int remAnagrams(String s,String s1)" ], "initial_code": "//saksham raj seth\nimport java.util.*;\nimport java.util.stream.*;\n\nclass Anagrams{\n\tpublic static void main(String[] args){\n\t\tScanner sc=new Scanner(System.in...
{ "class_name": null, "created_at_timestamp": 1615325282, "func_sign": [ "remAnagram(str1,str2)" ], "initial_code": "if __name__ == '__main__':\n t = int(input())\n for i in range(t):\n str1 = input()\n str2 = input()\n print(remAnagram(str1, str2))\n print(\"~\")\n", "...
eJzVl2uO0zAQx/nAAThClc8rtOlCWfYkSAShPJzEeYwdx3YeCMQh4Fp84z44bXeFuhkrSYsaRlYUyZnJz5Px35PvL3/+fvVibx9+mZuPXxwKXEnnYeNsPfCDMCJxktIsL0pgvBK1VLppu96DvmsbrWQtKs6gLPKMpklMojDwbX7LIuIzzs3GIS0noSTRZ6bkkf3Wg28eHK7O15vNX8tyDZ4fBGEYRYTEcZKkKaVZludFUZYAjHFeVULUtZRKad00bdt1/YDXD3dNo7VS0rCIquKcMYCyLIo8zzJK0zRJ4piQKArDIPAxOhfjwtM22TxA...
703,891
Area of a triangle
Given three sides of a triangle A, B and C in the form of integers. Find the area of the triangle.Note: The triangle may not exist. In such cases, the area is 0. Examples: Input: A = 2, B = 2, C = 3 Output: 1.984313 Explanation: The area formed by the triangle whose sides are 2,2 and 3 units respectively is 1.98431...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "double findArea(int A,int B,int C)" ], "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": [ "findArea(self,A,B,C)" ], "initial_code": "# Initial Template for Python 3\n\nimport math\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n A, B, C = map(int, input().strip().split(' '))\n ...
eJytU8EKwjAM9aD/EXqUUZp061a/RHDiQXfwMnfYQBDFj9D/tRtTNjF1TFMILeW95L2m1+kdZ5MmlnO3WZ3EPi+qUixAYJojuCUCENmxyLZlttscqrK9VjLUOs0vaS7OAbzhlAvoZIbDMSikWElMLEcFBJptwVEzOOsCXomtT5YMKqlN4pXSEBHDkpjIyoTQyxA90wgtGkKIGJzx4Mh5xzWNMtbEeo4szttnrTH8ItSoJvxyI1avD1hXtYMe/nv5kWAcMC9evOpPy8hxaaDjTOwp+Ksdn+TVP/XHCvSb452hpfY4gGV9kw8acnuO
703,800
K Smallests in the Original Order
Given an array, the task is to print K smallest elements from the array but they must be in the same order as they are in a given array. Examples: Input: arr[] = [1, 2, 2, 3, 1], k = 3 Output: 1 2 1 Explanation: In an array arr[] = [1, 2, 2, 3, 1] the smallest element is 1, the second smallest element is also 1 and ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1617640817, "func_sign": [ "public vector<int> kSmallestElements(vector<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...
{ "class_name": "Solution", "created_at_timestamp": 1617640817, "func_sign": [ "kSmallestElements(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 ...
eJzdms2OZjcRhmfBhVizjpBdLv9xJUgEsYAs2AxZBAkJReIi4GLZ8TzuHoIyPR2J5enMJJ3vO8cuV73l962y//Grf33oH+7Pb/8dHz787u8f//zp+7/+8PE35WP79tPLn4/flI/f/e377/74w3d/+sNf/vrD5+8//vhN+dnz9fPPuy/+96kvRxjl9Z9vP/WvDnAfeGP2EqWXfP/d+9Bb8ybvRuHX+Oq7fP32rM7bfmnWN979f+ab5X9sHe/46PWhN2ct9++3n/K9ud9+u5Wf4lfGT/H++jLaT4/9bDgcNvesLXOVvWOt2cco0VbdIyrv...
701,216
Max Circular Subarray Sum
Given an array of integers arr[] in a circular fashion. Your task is to find and return the maximum subarray sum that we can get, if we assume the array to be circular. Examples: Input: arr[] = [8, -8, 9, -9, 10, -11, 12] Output: 22 Explanation: Starting from the last element of the array, i.e, 12, and moving in a ci...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1731130205, "func_sign": [ "public int circularSubarraySum(int arr[])" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass Sorting {\n public static void main(String[] args) throws Exception {\n BufferedReader br = new BufferedR...
{ "class_name": null, "created_at_timestamp": 1731130205, "func_sign": [ "circularSubarraySum(arr)" ], "initial_code": "# Initial Template for Python 3\n\nimport math\nimport sys\n\nif __name__ == \"__main__\":\n T = int(input())\n while T > 0:\n arr = [int(x) for x in input().strip().split()...
eJydU0FuwjAQ5AC33vqBkc+4sh2chL4Eqa56aHPoxXAIEhJC4hHtf7trEJKLFxKSKFlFO7O7M+vj9Pd5NknX6omCt736jpttr16hbIg+RO2hLbSDrqAXag7V7TbdZ999fay3/TmV8tRhjhzchmgZm78EhrbEUIdocLkFZF1CWhMi9wuPGrpBiyXVNrDUhBOIGFNgYjKpti0hGhLNoYLjkam6hyRbIwydOjXIPmOnp6YT1DB4cDhOGl6PZOywRyIvbo87OejgzzKyoAskZSlOvjrWmOTlXxaSr67cvLgh1dgVyU6Jroh1xEG5JftVqjf3...
704,012
Find sum of even factors of a number
Given a number N, find the even factor sum of the number N. Examples: Input: N = 30 Output: 48 Explanation: Even dividers sum 2 + 6 + 10 + 30 = 48 Input: N = 18 Output: 26 Explanation: Even dividers sum 2 + 6 + 18 = 26 Constraints: 1 <= N <= 10**9
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int evenFactors(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 BufferedReade...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "evenFactors(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.evenF...
eJyVk00KwjAQhV30ICXrIpkxCaknEay40C7cxC4qCKJ4CL2XO69j6B+6eNOaVeHxNXlv3tyT5zuZNWf1ih/rizqE6lSrZaqoCFYXQWWpKs9VuavL/fZ4qjvVcRFuUb1m6S/jDGSIHYBI45vIQ4o9pNgaQLF1kLKkAWWJ8Qs1ozSihPNgbZC1KGFvRufIXJSwO085shclwZ9beGSwyWVk7CAePeQz0gAhp9Zva+B/1zQBZ2cc5IdJdcvCtogHTwD9iPs2C1MXm0nytgoNHSIQKyeE+J3hyHqJBfRioHlbs2mv7S/ZPOYfaOOCNQ==
703,829
Full Prime
Given a number N.Check if it is Full Prime or not.Note : A full prime number is one in which the number itself is prime and all its digits are also prime. Examples: Input: N=31 Output: 0 Explanation: N is prime but since 1 is not a prime so all the digits of N are not prime.So, Answer is 0. Input: N=37 Output: 1 ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int fullPrime(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 rea...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "fullPrime(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 ob = Solution()\n print(ob.fullPrim...
eJxrYJkqwsIABhG8QEZ0tVJmXkFpiZKVgpJhTJ6hko6CUmpFQWpySWpKfH5pCVTKICavLiZPqVZHAVW9EQ71hjjUG5Oo3oRE95iSaL45ieoNDUgNIFwhhEuDMS4v4PQyLj/g0mCIJ5xw6gEGlSkZmkj1PcQecmwyJ10XudaQrM8IiGNiyAoLcJoj26EQJpRHMO3GTtEDAHpaSn8=
700,238
Binary Search
Given a sorted array arr and an integer k, find the position(0-based indexing) at which k is present in the array using binary search. Examples: Input: k = 4 , arr= [1, 2, 3, 4, 5] Output: 3 Explanation: 4 appears at index 3. Input: k = 445, arr= [11, 22, 33, 44, 55] Output: -1 Explanation: 445 is not present. ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1616627406, "func_sign": [ "public int binarysearch(int[] arr, int k)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\npublic class GFG {\n public static void main(String[] args) throws IOException {\n ...
{ "class_name": "Solution", "created_at_timestamp": 1616627406, "func_sign": [ "binarysearch(self, arr, k)" ], "initial_code": "# Initial template for Python\n\nif __name__ == \"__main__\":\n t = int(input())\n for _ in range(t):\n k = int(input())\n arr = list(map(int, input().split()...
eJylU8sKwjAQ9KD/MeSskkej1i8RrHjQHrxUDxUEUTx7E/R/TdKn6BqModCmzUxnZ3Yv3cet13FrdjUP8yPbZLt9zqZgIslit5JMcLeSjPXB0sMuXeXpernd5+XRgTl7Nl9PfbwSFBeB4gRIGxAkFCJoEhwRYG7VQnIojohDh4iuqhXwFU5R6JqhrMPtUfn5Y01CqkiPyrtGsS1u45+lqZYqjDDGBLGpk+SRBI/5cxsPQQdNUbSMrgT5DNdfe8am7ekbMvW2L4GWNCIMOClfWElBgmyriHr6LE9AL9uUXER0OiTWqv9jduTbNCo0AXmT...
700,394
Strongly Connected Components (Kosaraju's Algo)
Given a Directed Graph with V vertices (Numbered from 0 to V-1)and E edges, Find the number of strongly connected components in the graph. Examples: Input: Output: 3 Explanation: We can clearly see that there are 3 Strongly Connected Components in the Graph Input: Output: 1 Explanation: All of the nodes are connec...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int kosaraju(int V, ArrayList<ArrayList<Integer>> adj)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.io.*;\nimport java.lang.*;\n\nclass Gfg\n{\n public static void main (String...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "kosaraju(self, V, adj)" ], "initial_code": "# Initial Template for Python 3\n\nfrom collections import OrderedDict\nimport sys\n\nsys.setrecursionlimit(10**6)\nif __name__ == '__main__':\n t = int(input())\n for i in ran...
eJytUzsOwjAMZehBrMwVapr0x0mQCGKADiymQyshIRCHgOOwcTDsqgNKm9BIdLASxe/5Pdu9R893tOi/9YsOm4s4YtO1YgVCGpQJyNQgRToDnVJIOCiDCrRBDZnBjK85FAYLKA2WUBmsIOdAryIGUZ+bet/Wh92pawdygtzo8RqDVZELODDSgUk9mNSJkYOvQKDyFHOZUtwhq4mBHjW3+5tC+aW4edSIx0GhHRQZj3Ukpd+GcD0ZL4rVmoHsh8PJAbnTJ9cmePb2HEPcJmxtrr4+eX42iQnxTe0lI4HuNfxjB/21p9TO/VO3j+UH/nx2...
703,455
Left out candies
Given n students sitting in a circle, distribute m candies to these students. The ithstudent can take onlyi candies. If ith student does not get the required amount ofcandieshe will not take it. Distribute the candies starting from the 1st student and moving along the circle of students till you reacha student you can ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public long leftCandies(long n, long m)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) throws Exception {\n ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "leftCandies(self, n, m)" ], "initial_code": "# Initial Template for Python 3\n\n# Position this line where user code will be pasted.\nif __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n n, m = list(ma...
eJxrYJm6mYUBDCLWABnR1UqZeQWlJUpWCkqGMXmGCkBCSUdBKbWiIDW5JDUlPr+0BCptAJSp1VHA0GAABiRqg2gi2TaYNgJ2AuUtcehXMDUwJcOxQG1AfSRrVDA1wakFqwtNgZ4zxmOPCQ57DMmJAXA44glEHBEOJCiPQYghlKQecqw2JFcjMP6hLHypwJSIECPHenDqw5NssdtrgBrWZKd9sBlExZYhXv8jhwKEQk7wBMMldooeAATIYlg=
709,863
Smallest Subset with Greater Sum
You are given an array Arr of size N containingnon-negative integers. Your task is to choosethe minimum number of elements such that their sum should be greater than the sum of the rest of the elements of the array. Examples: Input: N = 4 Arr[] = {2, 17, 7, 3} Output: 1 Explanation: If we only select element 17, th...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1729905887, "func_sign": [ "int minSubset(int[] arr)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass Geeks {\n public static void main(String[] args) throws Exception {\n BufferedReader br = new BufferedReader(new InputStre...
{ "class_name": "Solution", "created_at_timestamp": 1729905887, "func_sign": [ "minSubset(self, arr)" ], "initial_code": "# Initial Template for Python 3\n\nt = int(input())\n\nfor _ in range(0, t):\n arr = list(map(int, input().split()))\n s = Solution().minSubset(arr)\n print(s)\n\n print(\"...
eJytVbtOxDAQpEDiN1auT8jrZ0JFxy8gEUQBKWjCFTnpJATiI+B/8a4TH6+9S46srbETKTu2Z9Z5O/24OjvhuL5Mk5tn9ditN726AIVNh5oCagrGijEyBkbP6Bgto2FEtQLVbtftfd8+3D1t+iGrb7rXplMvK/hORQxER4AEhsASOAJPEAgiQUVQCxxB4EifgOdu/NBRD91zQ2pCVitk9fmQDI+APEKgASw9Afr0BLFCA7amPdQ+nVQMAg8KPAZddJUNLuZlfm0zU2VdB2GzsknatDxw4IVcRsqVvnOQ9AhgDYQklkmpfACPJKFxM9dW...
702,996
Sort in specific order
Given an array arr[] of positive integers. Your task is to sort them so that the first part of the array contains odd numbers sorted in descending order, and the rest of the portion contains even numbers sorted in ascending order. Examples: Input: arr[] = [1, 2, 3, 5, 4, 7, 10] Output: [7, 5, 3, 1, 2, 4, 10] Explanat...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public void sortIt(Long arr[])" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nimport java.util.ArrayList;\nimport java.util.Collections;\n\nclass GFG {\n public static void main...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "sortIt(self, arr)" ], "initial_code": "# Initial Template for Python 3\ndef main():\n T = int(input())\n while T > 0:\n arr = [int(x) for x in input().strip().split()]\n ob = Solution()\n ob.sortIt(a...
eJzs3TuuRVuSHVYZasjBs8vY/w9bIkAF0CDToJMsIwsgQBGQodaqFZpj7kdBVGUJlEcjKioy89137zn7s1as+MyY8b//z//L//Z//J//0//6n//4D3/9p3/+2x//5vfH+o9/Xf7xr3/8w++Pv/ynf/rLv/vbX/79v/2P//y3P//l8sd/+Yfff/vL6/Iv/u9f/fO/87v/8gOX3/Y7ftfv+a3/Hxfy//ilv3NN6+/93b/zt//rl/J//8q//PP799/Iv/oZ/6/f+5cftOXHR75n+f2dO8+/2/7Vj377ke7Sff53Pbe/9xV/72fvv/i/f/mj...
706,210
Reverse Bits
Example 2: Examples: Input: N = 11 Output: 13 Explanation: (11) 10 = (1011) 2 . After reversing the bits we get: (1101) 2 = (13) 10 . Input: N = 10 Output: 5 Explanation: (10) 10 = (1010) 2 . After reversing the bits we get: (0101) 2 = (101) 2 = (5) 10 . Example 2:
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1616012004, "func_sign": [ "public int reverseBits(int n)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.io.*;\n\nclass GFG\n{\n\tstatic int n;\n\tstatic int k;\n\t\n\t// Driver Code\n\tpublic static void main(String...
{ "class_name": "Solution", "created_at_timestamp": 1616012004, "func_sign": [ "reverseBits(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.reverseBit...
eJytVEEKwjAQ9KD/KMGbRXaTNml9iWDEg/bgpfbQgiCKj9D/mqa2YnFTI+YUWCYzu7OT6/g+m4zsWU7NZXVi+7yoSrYIGOocdM7CgGXHItuW2W5zqMpn0VQupngOg3cEkggkENwbIUiEoDjimMTYGoGS3toQOC2vKVK4yH90ECX+CrmIYqmSlDZXCjS9c0kOprHNxc4/0kPNb1odGi4KVE5ujd7c9Trjq/9Wgp1Do4qUQ64VRJ3lDiO4Sr8U1LPnj/q0P9tvLSF0i+lIQuLIgbC/iBUL9upwbCDbzsAh768jUO8oBNWGYX2bPwB7ApXi
704,027
Tidy Number
Given a number N.Check if it is tidy or not.A tidy number is a number whose digits are in non-decreasing order. Examples: Input: 1234 Output: 1 Explanation: Since 1<2<3<4,therefore the number is tidy. Input: 1243 Output: 0 Explanation: 4>3, so the number is not tidy. Constraints: 1<=N<=10**9
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "int isTidy(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 n...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "isTidy(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.isTidy(N))\n ...
eJxrYJm6hoUBDCKWAhnR1UqZeQWlJUpWCkqGMXmWFuZmpibGRoZKOgpKqRUFqcklqSnx+aUlUCUGMXl1MXlKtToKqPoMjYxNTM3MLSxx6DPEpQ+s0dTMzJxUjUZGxsbGJkBAokZLKLAg1YdQYESifeDQNAB6k0T7wKEJig0S9cEi0IBM/5GuDxiDQBrhUTyxidMQEs3BGdjgQCPX56R6HRg9pOYTaP4Cp4s8kD9Jz2ogP5Kby8jLK9SKZZBZWIwhaE7sFD0AQTxpIw==
712,266
Generate all binary strings
Given an integer N, Print all binary strings of size Nwhich do not containconsecutive 1s. Examples: Example 1: Input: N = 3 Output: 000 , 001 , 010 , 100 , 101 Explanation: None of the above strings contain consecutive 1s. "110" is not an answer as it has '1's occuring consecutively. Constraints: 1 <= N <= 20
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1665405536, "func_sign": [ "public static List<String> generateBinaryStrings(int n)" ], "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 ...
{ "class_name": "Solution", "created_at_timestamp": 1664780858, "func_sign": [ "generateBinaryStrings(self, n)" ], "initial_code": "# Initial Template for Python 3\nfrom sys import stdout\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n ob = So...
eJx01bGOtluTpGUMTgJvq+0xKjA5EiRGwmDGwGnGmJGQ0CDOGhdp+s31rJVx0d/eX1XfO+PPrIh4V/0///3//P/+1//hv/tf/q9/+d//9T/9l//8L//TP/+Sf/+v+Zd/98+//Mf/8z/9x//tP//H//C//h//5T///tPfP/nn3//r//3v//Vf/uu/++eV/I9//38a/N8/YAEMJiN5II8WRYuCRdGd0Z3RndGdwZ3/bc+e/G9Qk7UoMiQyJDIkMiQw5N/OJAyg5HXnv8GW951RcFFwUXBRcFFwUXBBcD8//gQ1GUzuRT/Y8jLkBzXZi9qQ...
700,280
Unique rows in boolean matrix
Given a binary matrix your task is to find all unique rows of the given matrix in the order of their appearance in the matrix. Examples: Input: row = 3, col = 4 M[][] = {{1 1 0 1},{1 0 0 1},{1 1 0 1}} Output: $1 1 0 1 $1 0 0 1 $ Explanation: Above the matrix of size 3x4 looks like 1 1 0 1 1 0 0 1 1 1 0 1 The two u...
geeksforgeeks
Easy
{ "class_name": "GfG", "created_at_timestamp": 1615292571, "func_sign": [ "public static ArrayList<ArrayList<Integer>> uniqueRow(int a[][],int r, int c)" ], "initial_code": "import java.lang.Math;\nimport java.io.*;\nimport java.util.*;\nclass UniqueRows{\npublic static void main(String[] args)throws IOEx...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "uniqueRow(self, row : int, col : int, M : List[List[int]]) -> List[List[int]]" ], "initial_code": "# Initial Template for Python 3\n\ndef main():\n testcase = int(input())\n while testcase:\n s = input().split()\n...
eJztXcuOG0UUDRIf0hrdZYS6ZzJkhi9BIogFZMEmZJFISAiJXwDBz7Iiicd2ncet6rZbIKGbUmbG7upT93HOdVdX2f7t878+++PZp39f//37s2ff/HLz45u379/dfDXdLK/eLNOHH/OrNzfPp5vXP799/f271z9899P7d0895ilufn0+mXOW9JzFn/PiwyjztEw7/u+Yves4zqEXn8afp3VtWdd6ecisOMS1WrVq1apVq1atWrVq1f6V1pm27NvyGdDKCVa1atWqVatWrVq1atWqXds6i2H7tt4MaN9Vr8Oi1X4/98Yrf8vf8rf8LX/L...
703,123
Equal point in a string of brackets
Given a string str of opening and closing brackets '(' and ')' only. The task is to find an equal point. An equal point is an index (0-based) such that the number of closing brackets on the right from that point must be equal to the number of opening brackets before that point. Examples: Input: str = "(())))(" Output:...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1616522889, "func_sign": [ "public long countSub(String str)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\nclass GFG {\n\tpublic static void main(String[] args) throws IOException\n\t{\...
{ "class_name": "Solution", "created_at_timestamp": 1616522889, "func_sign": [ "findIndex(self,str)" ], "initial_code": "# Initial Template for Python 3\n\ndef main():\n T = int(input())\n\n while T > 0:\n str_ = input()\n ob = Solution()\n print(ob.findIndex(str_))\n\n T...
eJxrYJk6mYUBDCJ6gIzoaqXMvILSEiUrBSXDmDwNTSUdBaXUioLU5JLUlPj80hKEXF1MnlKtjgKaBg0cGgxwaNDEZYMRLhs0cToKpxYNTSDA5TITPLpw6cFlE1AHzhDA7TrcenCHmibOgDPFZw8YaCIArujFHb9wQ2A8mFGIgMZtLE5TyUk6ZIQbyKIYmMNxpz3itJNuOyKIkA1CiJLjIpxpFF9gI3kCyU2k2w3xCk6d+LIWTncbQzXFTtEDAMNBXf4=
702,778
Next Smallest Palindrome
Given a number, in the form of an array Num[]of size N containing digits from 1 to 9(inclusive). The task is to find the next smallest palindrome strictly larger than the givennumber. Examples: Input: N = 11 Num[] = {9, 4, 1, 8, 7, 9, 7, 8, 3, 2, 2} Output: 9 4 1 8 8 0 8 8 1 4 9 Explanation: Next smallest palindrome ...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "Vector<Integer> generateNextPalindrome(int num[], int n)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n // Driver code\n public static void main(String[] args...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "generateNextPalindrome(self,num, n )" ], "initial_code": "# Initial Template for Python 3\n\n# Driver code\nif __name__ == \"__main__\":\n tc = int(input())\n while tc > 0:\n n = int(input())\n num = list(m...
eJzs3buud0lyJXYZ8vQSgTJk0WDu++aTCBABGmQb4/S00Q0QGAwwb6hXUtXJ+GXsj5eRxo9ZU9VVX53zv+TOjIxYsVbwf/zv/9f/83/8n//b//3ffvsvf/7L3/762z/Eb+Mf/zz//29/F7/96V//8qd//uuf/uWf/uvf/pr/ffvtv/9d/Luff//Tnx8x/v1vbL//RvzPfufv/6PfOn9/q9hi//2v//zz/fETxx8/8e9///L7/39e4T95jf33jxG/4z/97TOuOP/97x3e+/ifvO8fn+w/eM/ff+X4//jMx8/vHv/+d+8/VnrE+us/fYX5...
706,299
Minimum X (xor) A
Given two integersAandB, the task is to find an integerXsuch that(X XOR A)is minimum possible and the count of set bit inXis equal to the count of set bits inB. Examples: Input: A = 3, B = 5 Output: 3 Explanation: Binary(A) = Binary(3) = 011 Binary(B) = Binary(5) = 101 The XOR will be minimum when x = 3 i.e. (3 XOR ...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1619456948, "func_sign": [ "public static int minVal(int a, int b)" ], "initial_code": "// Initial Template for Java\n\nimport java.util.*;\nimport java.io.*;\nimport java.lang.*;\n\nclass GFG {\n public static void main(String[] args) throws IOExcept...
{ "class_name": "Solution", "created_at_timestamp": 1619456948, "func_sign": [ "minVal(self, a, b)" ], "initial_code": "# Initial Template for Python 3\n\nimport atexit\nimport io\nimport sys\n\n_INPUT_LINES = sys.stdin.read().splitlines()\ninput = iter(_INPUT_LINES).__next__\n_OUTPUT_BUFFER = io.StringIO...
eJztnE2uLElWhBmwkNIbt5D//7ANJkg8xABqwOTRg2oJCSH1IpqtMGNv2GfHIyLzFrfUPWJyn0pd2fkiI9yPn2Nm5yfqj3/9X//zd3/lP3//3/rwD//x7V9//P4Pv3z725++5e8/kv/59rufvv3877//+Z9/+flf/unf/vDL+fv07T9/99P79Tldf94/f3KH55Jf3+rPu8PKO//2Mv6y9fufz1b76+unri+f/mB8+IGu7JdN++fL+v6jfnyS7Vlq62Ou/f3HXnP0Vkv++vbr269vv779+vbr269vv779//j2M7UUF+/nd18fvz5+ffz6...
713,143
Last modified ball
Samwell laid out N bowlsin a straight lineand put a few marbles randomly in each bowl, i**th bowl has A[i] marbles. A bowl can never have more than 9 marbles at a time. Abowl can have zero marbles. Now Samwells friend adds one more marble to the last bowl, after this addition all the bowls must still be aligned with th...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1671445250, "func_sign": [ "int solve(int N, int[] A)" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass FastReader{ \n BufferedReader br; \n StringTokenizer st; \n\n public FastReader(){ \n ...
{ "class_name": "Solution", "created_at_timestamp": 1671445250, "func_sign": [ "solve(self, N, A)" ], "initial_code": "# Initial Template for Python 3\n\nfor _ in range(int(input())):\n n = int(input())\n array = [int(i) for i in input().split()]\n obj = Solution()\n print(obj.solve(n, array))...
eJzs3cvOLctyHWY33DPgZwicNht1v+hJDJiAGhIb6lBskIAAQYDfxK/qvWfEl1GbEm2rnwqdw3XW+v85q7Iy4zrGqP/rf/0//u//7X//X/7P//q3//SP//Qv//y3fxd/W//+H//4/8vf/+Pf/i7+9g//5Z/+4T/88z/8x3//n//ln/373/7b38V/9/PP/8zP73/8Srzx/s/8zvnHNUXZv/l753//e/cf1/bnd7H/me+8/rjUOOKMK+7Y/s3fvP4HK7L8+f/+1VdPmzZt2rRp06ZNmzZt2rRp06ZNmzZt2rRp06ZNmzZt2rRp06ZNmzZt...
714,324
Palindrome with minimum sum
Given a string,S.The string can contain small caseEnglish letters or '?'. You can replace '?' with any small English letter. Now if it is possible to makethe string S a palindrome after replacing all'?' then find the palindromic string with a minimum ascii sum of the absolute difference of adjacent characters. Otherwis...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1679289967, "func_sign": [ "public static int minimumSum(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 BufferedRe...
{ "class_name": "Solution", "created_at_timestamp": 1679289967, "func_sign": [ "minimumSum(self, s : str) -> int" ], "initial_code": "if __name__ == \"__main__\":\n t = int(input())\n for _ in range(t):\n s = (input())\n obj = Solution()\n res = obj.minimumSum(s)\n print(...
eJy1VEFOwzAQ5MCBZ0Q+F9QEUSEu+wRuCAkj5CQu4mIqmtAkCMQj4L94HQs5rddOFNiqqeM065nZnf08/r45OTJxe60Xd2/sSW3qil0lLOUKAHKwF7ZImGw2sqhk+fBcV/ZfS64+uGLvi8R5NeOqgxYa2MEr1FDBlqsX2OpFrTd2+kELHZHwNDUZ7c9eYr0pNJoCSpCwhke9ykGEMx2mACKmUDRIfEGhobJ0+FKrvw1oZYw8uMQdUqNLClFelHINa1kWOYUjpSrWo//9YCDHQSGD3Px6XyAs7CFhj8B7UQi8R7yAWPGRMH0myDJkJnt/...
704,188
Maximum number of unique prime factors
Given a number N, find the maximum number of unique prime factors any number can have in range [1, N]. Examples: Input: N = 3 Output: 1 Explanation: No number in the range 1 to 3 can have more than 1 unique Prime factor. So, the Output is 1. Input: N = 500 Output: 4 Explanation: No number in the range 1 to 500 can ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int maxUniquePrimeFactors(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 Buffe...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "maxUniquePrimeFactors(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 prin...
eJxrYJm6jIUBDCLmAxnR1UqZeQWlJUpWCkqGMXmGBgYGMXlKOgpKqRUFqcklqSnx+aUlUHmTmLw6oGStjgKmJty6TPHpwq3NDK823PrM8evDrdGCgEYKdOLWaolLK04dBjh0GOHUYYhDhxlOHUY4PQSxCL+fjHHpRg1Mcm2PgbqBdPshiGCc4AlhItIfrtBG0h0TQ7p2QwLZBWeyN0RLiGTGHTTmgU7Pw5vYcBmA7n0gB08ih4VC7BQ9AM94dA4=
703,050
Greater on right side
You are given an array arr. Replace every element with the next greatest element (the greatest element on its right side) in the array. Note: There is no element next to the last element, so replace it with -1. Examples: Input: arr[] = [16, 17, 4, 3, 5, 2] Output: [17, 5, 5, 5, 2, -1] Explanation: For 16 the greatest...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static ArrayList<Integer> nextGreatest(int arr[])" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass Main {\n public static void main(String args[]) thr...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "nextGreatest(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 ...
eJzsndvObrlylkHiQobWcYbk8q5srgQJJA4gB5yEHAQJCSFxwr1xWbzPa8/uhZi9sl1hhYxM6Ix0f/P/x+eyy2XXu/kf/+rf/M//9S//xb/9b7/7T3/xl//lr373r5/fxb/7izfKj//5d3/xuz97fvfn//Uv//w//NWf/8d//5//y1/dj73xu//+Z8//+ff+rn/tqU97+jOe+eSznv1EeSKeqE+0J/oT44n5RD6xnthPLU/V36lPbU/tTx1PnU/Np66n7qeVp8XT9CPb0/rTxtPm0/Jp62n76eXp8fT6dP3G/vTx9Pn0fPp6+n5GeUY8...
705,067
Juggler Sequence
Juggler Sequence is a series of integersin which the first term starts with a positive integer numberaand the remaining terms are generated from the immediate previous term using the below recurrence relation:Given a number n, find the Juggler Sequence for this number as the first term of the sequence until it becomes ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static List<Long> jugglerSequence(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 Buf...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "jugglerSequence(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 arr = ob.j...
eJytlMFKAzEQhj2IF28+wc+ei2QmmSTjkwhWPGgPXtYeWhBE8SH0ff1bK+oh6YpdFnY3Yf58M//Mvh6/n50cba/LU75cPQ3343K9Gi4wyHzkPcwwLB6Xi9vV4u7mYb362sR8fOHu8wy/Q7QZomgGxWZQhEEEMSOjIyAhtFFDgARMVHJvCrnDqyEGF4qlaGIKjVGoq5aoXYolLTxBUkKpqL2TrI1sAQVSkXrxxZrxxZCTQ7LFCCVc1QRJVhFrP/3aTr86anRoioECxmq6cikVZRVckDwz6dBPOpa21QWqLG8sG+kcMsVzlVrI7lEKqvPB...
701,750
Shortest Common Supersequence
Given twostrings X and Yof lengthsm and nrespectively, find the length of the smallest string which has both, X and Y as its sub-sequences.Note:Xand Y can have both uppercase and lowercase letters. Examples: Input: X = abcd, Y = xycd Output: 6 Explanation: Shortest Common Supersequence would be abxycd which is of ...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1731653676, "func_sign": [ "public static int shortestCommonSupersequence(String s1, String s2)" ], "initial_code": "// Initial Template for Java\n\n/*package whatever //do not write package name here */\n\nimport java.io.*;\nimport java.util.*;\n\nclass...
{ "class_name": "Solution", "created_at_timestamp": 1731653676, "func_sign": [ "shortestCommonSupersequence(self, s1, s2)" ], "initial_code": "# Initial Template for Python 3\n\n# contributed by RavinderSinghPB\nif __name__ == '__main__':\n t = int(input())\n for tcs in range(t):\n X = input(...
eJzFlVtPgmAYgLvooh/RhaNb19KsVncgCHgABVSkrzUOH3j8QAVPra0fUf83soM2+UScLTccMPbwHp735eX47ezkaPlTT8OT+yeig7zAJ+5SRAYg3TAtaDvtThegXn+AXG84GvtEOkXAmQdNH1qPbuB/PZ+9AIh4Tqc2EbP5IqQAFHJCSgjBEDK3UYRak5GUVp0XqwCRMl1guWKpnIig64ZhmpYFoW0D5Di2DaFlmaZh4FLJRmG+8w8m0zAjgBbz2XQS+OPR0HPRoN/rdtqODS3T0DHYy8joSJ0y8iZtMbBgsw7X5jvFsNzaojVXZ81p...
700,883
Find the Frequency
Given an Array Arrof N positive integers and an integer X. Return the frequency of X in the array. Examples: Input: N = 5 Arr = {1, 1, 1, 1, 1} X = 1 Output: 5 Explanation: Frequency of 1 is 5. Input: N = 6 Arr = {1, 2, 3, 3, 2, 1} X = 2 Output: 2 Explanation: Frequency of 2 is 2. Time Complexity: O(N) Space Comp...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1731653688, "func_sign": [ "int findFrequency(int arr[], int x)" ], "initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.util.*;\nimport java.util.stream.Collectors;\n\npublic class Main {\n\n public static void main(String[] ...
{ "class_name": "Solution", "created_at_timestamp": 1731653688, "func_sign": [ "findFrequency(self, arr, x)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input())\n for _ in range(t):\n arr = list(map(int, input().split()))\n ob = Soluti...
eJztlksKwjAQhl249wo/WYtMH4mNJxGsuNAu3FQXFQQRPISew53nsw9EqY02mtJSTUomNJ00yXz5mUP3dOl10jI+x53Jji3D9SZiIzDLD5OH9cGC7TqYR8FittpE91G27yP3PSVF7URFTjYqr/FPFCvihUvK9oG/qcLcjlczIrAJDsElcIIgDAkeQaaz+qFQTafg9PVsFmkRLJOCf1ui1dSGUsQUhxgtqS8kmBQ7t+HABYfAEB5kzLQfcn0dF1lHP16NkJn8NupeVMuYNH9Eb25503lrkSkZEVe2Snh5AeVK5VXTKD7TzSQRJnJ/E/5v...
703,001
Ordering of strings
You will be given N number of strings. You have to find the lexicographically smallest string and the lexicographically largest string among these strings. Examples: Input: N = 3 strings = a , ab , abc Output: a abc Explanation: Lexicographically smallest is "a" and lexicographically largest is "abc". Input: N = 2 st...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "String[] orderString(String s[], int n)" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nclass GfG\n{\n public static void main(String args[])throws IOException\n {\n Scan...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "orderString(self, s, n)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n\n for tcs in range(T):\n n = int(input())\n s = input().split()\n ob = ...
eJytVdmu0zAQ5YEX/uIoz1eIe9kkvgSJIDRJJksXOzdJaRtExUfAN/HGNzF22iy3dRwJpm7j2pkz2/H4x/Nff148s/Lxt0w+fQsKVe6a4AOCh1C9DVWLw7ElHNoWFMUJp1lerNabrdLlY1U3u6972Z/ZkhGq16EikBkU3CHgQ8lxw8kXvWvOxmawRf/U6ZOdBd/vMHLzPlT3r2Q/AsWgBMSgFJSBclABWoHWTqOy58B8I5CDoB0E217wOIjLxm2QW1YlS+/EalluGBEp+UBXpDJGyVQhq6hkrIt9ESqpTctRJXU5bnSZa8U2yXWca72B...
714,008
Equal Left and Right Subarray Sum
Given an array A of npositive numbers. The task is to find the first index in the array such thatthe sum of elements before it is equal to the sum of elements after it. Examples: Input: n = 5 A[] = {1,3,5,2,2} Output: 3 Explanation: For second test case at position 3 elements before it (1+3) = elements after it ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1676012432, "func_sign": [ "int equalSum(int [] A, int N)" ], "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\t\...
{ "class_name": "Solution", "created_at_timestamp": 1676012432, "func_sign": [ "equalSum(self,A, 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\n A = [int(x) for x in input().strip().split...
eJzFlEtOwzAQhlkgzvHL64L8iN2UkyDVqAvIgo3pIpWQEIgrIIHEcTu245amdpC7oHasjJx4vnn64/L75+oijLtPEpav7MmtNz27BVPWCU4LEgoNNAzmaLGA351bJzlJUBxNEDS0dcb/n6ZmM7DuZd099N3j6nnTD4qvhXXv1h2+2NsMI7jnx2Ed6Vbw04AY7d6swKZZYB0wdI4kSZf8bbYgxk4mLJ0j50SJMOkGKV54N5B92uiYIO3pMSdhhM+GdaT0KFmcVkuyob2GvkmIUqhKqveJmAxyxqaQpmmHsqfKRhZPqZjCapoKtEre0BoN...
714,170
Unequal Arrays
You are given two arrays A and B each of length N.You can perform the following operation on array A zero or more times. Examples: Input: N = 3 A[] = {2, 5, 6} B[] = {1, 2, 10} Output: 2 Explanation: Select i = 3, j = 2, A[3] = 6 + 2 = 8 and A[2] = 5 - 2 = 3 Select i = 3, j = 2, A[3] = 8 + 2 = 10 and A[2] = 3 - 2 = ...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1678367956, "func_sign": [ "public static long solve(int N, int[] A, int[] B)" ], "initial_code": "import java.io.*;\nimport java.util.*;\nclass IntArray\n{\n public static int[] input(BufferedReader br, int n) throws IOException\n {\n Strin...
{ "class_name": "Solution", "created_at_timestamp": 1678367956, "func_sign": [ "solve(self, N : int, A : List[int], B : 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()] ...
eJy1lD1uFEEQhQkIOMbTxAZ19f+YjFMgsRaB2YBkcLCWLFm2fAi4L+/1jkcmaJtm8Uq7211d/aqm6qt5ePvr07s37fP5Ixdfbqfvy9X1YTrHZLsl7RZzsATv4BOCo0lr05qW3TKdYdrfXO0vD/tvX39cH9a773n5nqd3Z/hTMUvRITlkh+IwO1SqmjVD0k624salI2UQkFB2i0dERh0X4d0Ci/AGXxESIqVmKkcUbWmMs4zeuuKuo810KizDRwSqOsSKlJGZeI5acU8rz+hhz6Xfi2AqJTyrQD0WoKBiRrOyrNwUGvlMdPAYfwATD631...
703,457
Min and Max in Array
Given an array arr. Your task is to find the minimum and maximum elements in thearray. Examples: Input: arr = [3, 2, 1, 56, 10000, 167] Output: 1 10000 Explanation: minimum and maximum elements of array are 1 and 10000. Input: arr = [1, 345, 234, 21, 56789] Output: 1 56789 Explanation: minimum and maximum element o...
geeksforgeeks
Easy
{ "class_name": null, "created_at_timestamp": 1719569615, "func_sign": [ "public Pair<Long, Long> getMinMax(int[] arr)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass Pair<K, V...
{ "class_name": "Solution", "created_at_timestamp": 1719569615, "func_sign": [ "get_min_max(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 ...
eJydVMtOxDAM5AD/Mcp5jZK26YMvQWIRB+iBS9lDV1oJgfgI+DRufAxxTMsixWmXOUyrJvaM3Thv5x9fF2cR15/h5ebZPA67/WiuYNx2cChQooJHjQYtOji7HcwGpj/s+vuxf7h72o/T/rj4GtZfNvibRw+y0GLIWQsqmEqmislbPRUvgqOUhI4BpiJyGbmK7CPXem1zbK3aDWaD1WA02ATVoAbUgjr2pJt27FlzbBnoGGgZaBioGfAMVAyUDBSMaNMtlRJTZ1rPwiTKJNIk2iTiJOok8iT6JAYo72BO/7MtXXvunOV9H3kX//PnRU+8...
702,959
Column name from a given column number
Given a positive integer, return its corresponding column title as appear in an Excel sheet.Excel columns has a pattern like A, B, C, … ,Z, AA, AB, AC,…. ,AZ, BA, BB, … ZZ, AAA, AAB ….. etc. In other words, column 1 is named as “A”, column 2 as “B”, column 27 as “AA” and so on. Examples: Input: N = 28 Output: AB Expl...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1617893891, "func_sign": [ "String colName(long n)" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nimport java.lang.*; \nclass GfG\n{\n public static void main (String[] args)\n {\n \n Scann...
{ "class_name": "Solution", "created_at_timestamp": 1617893891, "func_sign": [ "colName(self, n)" ], "initial_code": "# Initial Template for Python 3\n\nt = int(input())\nfor tc in range(t):\n n = int(input())\n ob = Solution()\n print(ob.colName(n))\n\n print(\"~\")\n", "solution": "class S...
eJxrYJlaxcoABhHFQEZ0tVJmXkFpiZKVgpJhTJ65gVFMnpKOglJqRUFqcklqSnx+aQlUOioqJq8OKFuro4CuyRinJkdHRxy6DC2MzC3x6cOl0cTc1MjUBI8zcTrU0AAMcGp1cgl398Oh18jQxNzEwtjMxByndreIYI+giHBcluPyKS4LzXB5EJcGc5xhiUOHqREuHThDEBH8+JIKLguBKQUtKHEa4eXlTSD+8YQpvjSA7APkNEG6b6ApGByQOEOSQDqGuAiEUMIVb/LGlcJwGEjA0+TbR7GVlCUhqrmAgrQITALgnEcwHTgFwTwUO0UP...
704,789
Number of paths
The problem is to count all the possible paths from top left to bottom right of an MxNmatrix with the constraints that from each cell you can either move to right or down. Examples: Input: M = 3 and N = 3 Output: 6 Explanation: Let the given input 3*3 matrix is filled as such: A B C D E F G H I The possible paths w...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1730882823, "func_sign": [ "public int numberOfPaths(int m, int n)" ], "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 BufferedReader ...
{ "class_name": "Solution", "created_at_timestamp": 1730882823, "func_sign": [ "numberOfPaths(self, m, n)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n ob = Solution()\n t = int(input())\n for _ in range(t):\n M, N = map(int, input().split())\n ...
eJydlMFKAzEQhj3oe4Sci2QmM5PE9xAKVjzoHrzUHrZQEKUPUd+3adxuQZ0EM4clkP3/zXzzZ/fXX6ubq1LL+7x4eLev6812tHfGwmoNJj/swthhtxmex+Hl6W07XrY/8+bHwvzQuB6RAdclmqrjlM4VuapMwuIgECoOnA24okchRA9R0wN6YiMhJtVCREIiiVGxQJOm0ruYX1CH1WQYUsKEFKTC8oyz5sMELoWMtDWTXwfT22MUYHZ6f8WnrBSLzBcT4Sl/KuRvpybqWtgaaQsS2UeGVl7nu/IPSF7Qhygao5Ki6RPNMFXu4smh73fh...
703,444
Minimize the Heights II
Given an array arr[]denoting heights of N towers and a positive integer K. Examples: Input: k = 2, arr[] = {1, 5, 8, 10} Output: 5 Explanation: The array can be modified as {1+k, 5-k, 8-k, 10-k} = {3, 3, 6, 8}.The difference between the largest and the smallest is 8-3 = 5. Input: k = 3, arr[] = {3, 9, 12, 16, 20} ...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1616729438, "func_sign": [ "int getMinDiff(int[] arr, int k)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) throws Exception {\n BufferedReader br = new BufferedRead...
{ "class_name": "Solution", "created_at_timestamp": 1616729438, "func_sign": [ "getMinDiff(self, arr,k)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n k = int(input())\n # n = int(input())\n arr = list(map...
eJzNlU1KBEEMhV0ILtx5gkevRSpJpX48ieCIC52Fm9bFCIIIHkLva1KOMGqVjujChoammn7J+/Kq+nH3+WBvp10n+/Zwej9dzTe3q+kYEy1mWcwRFEAKjhCGCKQgRsSEWKFhOsS0vLtZXqyWl+fXt6v1tzEs5unhEO/leDETEohBBawQgmRERcxQHknlnpSaGgooggmcW2PVu1KGFiRGUuSAnAayKfZkbdHscoAExGD+kILLlIBqGMLIb+GeWnK/AkVtnhVUwQIuLi/qFSKPIUrXuS2a79xMJ4en4naz4SBvstrbkEFezoZGMpKnUHr6...
708,157
Maximum Number of Toys
You are given N toysin a shop. The cost of each toy is represented by an array A[]. You are given Q queries, For ithquery, You have a C amount of money which you can use to purchase the toys. Also there are K broken toys and you won't purchase them. The task is to calculate the maximum number of toys you can purchase u...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1630945498, "func_sign": [ "ArrayList<Integer> maximumToys(int N, int A[], int Q, ArrayList<Integer> Queries[])" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\nclass GFG {\n static cla...
{ "class_name": "Solution", "created_at_timestamp": 1634906189, "func_sign": [ "maximumToys(self,N,A,Q,Queries)" ], "initial_code": "for _ in range(int(input())):\n N = int(input())\n A = [int(i) for i in input().strip().split()]\n Q = int(input())\n Queries = [[] for _ in range(Q)]\n for i...
eJztlz2OFDEQhQnIuUJp4hXyb9vmJEgMIoANSAaCRUJCIA4BZNyVqveqp5tlDcuPSMC7dA9gf+2q96o8/f7ux8/37mA8/KQfHr05PD+9fHV1eCCHeDzFoH+qxCApSJWEj3qp9vdUj6esv0GyRCmyHE816Kdq64Lo0sOFHC5fv7x8enX57MmLV1cOzorocjy90xlvL+SGR8o3P/qPirc92JN0eZzz65RtO1ZGkyFRodkiiU3ikBQlZQswNUlDss5OiKdYRBZ2/GFcVbGTJ6eAxTpk2JBuQ5oNWWxItSHFhmQbkmzoRmO8ISFrSgidbypO...
702,754
Pairs with certain difference
Given an array of integers,arr[] and a number,K.Youcan pair two numbers of the array if the difference between them is strictly less than K. The task is to find the maximum possible sum of suchdisjoint pairs (i.e., each element of the array can be used at most once). The Sum of P pairs is the sum of all 2Pelements of p...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1617737056, "func_sign": [ "public static int maxSumPairWithDifferenceLessThanK(int arr[], int N, int K)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\nclass GFG {\n\tpublic static void ...
{ "class_name": "Solution", "created_at_timestamp": 1617737056, "func_sign": [ "maxSumPairWithDifferenceLessThanK(self, arr, N, K)" ], "initial_code": "# Initial Template for Python 3\n\ndef main():\n T = int(input())\n\n while T > 0:\n N = int(input())\n arr = [int(x) for x in input()...
eJytVMFOwzAM5YD4DqvnCdVJkyZw4yuQCOIAO3AJO2zSJATiI+B/efY2xKS6tBOtnlu1fc5znt2P86+bizM9bq9xc/faPNfVZt1cUcOlcguQI08dBYrUU6JM8jQ0C2qW29Xycb18enjZrPekEEp9L7V5W9BxqiTZWnAZcIAHOiAAEehLdUbS5JKRlV2pHUQxskRy0OkotBQSRaiFXKacZWUjc+ejlTmo4JacBC+hkxAkRAm9hCQht1qZRuWwklhZrDQWHirExZDCnPWTQTUOL7BhsIFhRIYlEVcPiCE94NWmRF2pvbFC7q1ad6VqNLim...
704,436
Product of factors of number
Given a number N. Calculate the product of all factors of N. Since Answer can be very large,compute the answer modulo 10**9+7. Examples: Input: N=6 Output: 36 Explanation: Factors of 6 are 1,2,3,6.Their product is (1*2*3*6)%(10 **9 +7)=36. Input: N=25 Output: 125 Explanation: The factors of 25 are 1,5 and 25. So,...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "int factorProduct(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": [ "factorProduct(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.factor...
eJyVkz1OBDEMhSn2IKPUKxT/xI45CRKDKGAKmmGLWQkJgTjEUnFZwjK7guJFwtVImc/Pz3l533x8bi6OdX1oHzcv6XHe7Zd0NSQaZ8qnStshTc+76X6ZHu6e9sv6T5XwHEY+zm/jnF63w98G8VPigD+fA55YtJjXADyTZDXOhPSrW1FhArxROEfzAHgmda1iigys5yKggRgCc3a3MMApciyKpCoyWSJrAMgUbTaHU2F0L5kR6GZuLNgZihKU6keQS8uftVtE/PdmkCjKDcFlthO0f5QxxZOd5+sIdnx1F9MBf6+1F7Z+i1X+/5Pz8WH0...
700,712
Alternates in an Array
You are given an array arr. You need to print elements of arr in alternate order (starting from index 0).Examples: Examples: Input: arr[] = [1, 2, 3, 4] Output: 1 3 Input: arr[] = [1, 2, 3, 4, 5] Output: 1 3 5 Constraints: 1 <= arr.size <= 10**5 1 <= arr[i] <= 10**5
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1616688308, "func_sign": [ "public static void print(int 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\n Buffere...
{ "class_name": null, "created_at_timestamp": 1616688308, "func_sign": [ "printAl(arr)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input())\n for i in range(t):\n arr = list(map(int, input().split()))\n printAl(arr)\n print()\n ...
eJztmsGKJUUQRV34IUG7Fcm4EZWV5ZcIjrjQWbgZXYwgiOJH6A+68y88kR2CKG/UcYQZ573eNLyoqox7Iu+tqu4f3v3pl/fe2Z+PfuaXj799+OLZV18/f/jQHvzJMx922bLTph2WFibzh/ft4ek3Xz397PnTzz/98uvnv1UPCidFsifPvn/y7OG79+0PJzvM0zzMOYvbPzn3sQ9zDjgp5teb1xic9bJr2XXaNe067Eq7wi7ZxfEskosuW6etaeuwlbbClmy5rWEnV2BNp53TzsPOtDPslJ1u57B52aRJljxtHjbTZtiUTbc57LjsWHaw...
701,158
Count total set bits
You are given a number n. Find the total count of set bits for all numbers from 1 to n (both inclusive).Examples : Examples: Input: n = 4 Output: 5 Explanation: For numbers from 1 to 4. For 1: 0 0 1 = 1 set bits For 2: 0 1 0 = 1 set bits For 3: 0 1 1 = 2 set bits For 4: 1 0 0 = 1 set bits Therefore, the total set bit...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public static int countSetBits(int n)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\nimport java.math.BigInteger;\n\n//Position this line where user code will b...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "countSetBits(self,n)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n for _ in range(int(input())):\n ob = Solution()\n print(ob.countSetBits(int(input())))\n print...
eJylVMtOxDAM5AD/UeW8QrFjJw7iQ1baIg7QA5eyh66EhEB8BPwv3t2sBIdpecypUjP2eMbJ2/nH9cXZAWv1j81zeBi3uylcdYH6keIRYdWF4Wk73E3D/e3jbjqdIJEkOXE/vvZjeFl13+kqiQlwhYxYAbFayU6GbblyERbEbkD05LKlUER8nZ/a52VOmhHdC5uWjLof/xIgpwbomlryEhXQrQE6p8rFayDtpQGKj5ojVUpodk6iucD+vi4+HKHcDwuznKBSihYNaVhgc2GzKowLtPzjD4qRmOTK5sbOJ/rF3IVw4V43c3+tcO85pwz1...
713,195
Type it!
Geek is extremely punctualbut today even he is not feeling like doing his homework assignment. He must start doing it immediately in order to meet thedeadline. For the assignment, Geek needs to type astring s. To reduce his workload, he has decided to performone of the following two operations till he gets the string. ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1671618553, "func_sign": [ "int minOperation(String s)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader read ...
{ "class_name": "Solution", "created_at_timestamp": 1671618553, "func_sign": [ "minOperation(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 ans = ob.minOperation(...
eJxrYJm6lIUBDCLmARnR1UqZeQWlJUpWCkqGMXmJSjoKSqkVBanJJakp8fmlJQipupg8pVodBTT1STg0GOHSgMsGnBqScNphjFNLMjLC5SUD3NpTkDEO/ZZ4tKemIZO4HIDL/RUkRkJFJQji0GSK15npOHSZ47IKbh1OC3FHJCxKDLEEMlnRBEJwY/ElLkOc6ZdgSODyDkIjblvxWEqVgAQjXLkDp5+TU3B61gSflUQHtgX+jJVHKGcZwlJf7BQ9ANkCj00=
700,444
Count distinct elements in every window
Given an array of integers and a number K. Find the count of distinct elements in every window of size K in the array. Examples: Input: N = 7, K = 4 A[] = {1,2,1,3,4,2,3} Output: 3 4 4 3 Explanation: Window 1 of size k = 4 is 1 2 1 3. Number of distinct elements in this window are 3. Window 2of size k = 4 is2 1 3 4....
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1616001439, "func_sign": [ "ArrayList<Integer> countDistinct(int k, int arr[])" ], "initial_code": "import java.io.*;\nimport java.util.*;\nimport java.util.HashMap;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n ...
{ "class_name": "Solution", "created_at_timestamp": 1616001439, "func_sign": [ "countDistinct(self, k, arr)" ], "initial_code": "import sys\nfrom collections import defaultdict\n\nif __name__ == '__main__':\n input = sys.stdin.read\n data = input().splitlines()\n t = int(data[0])\n index = 1\n...
eJzFlEEOgjAQRV0YzzHp2hhaoKAnMRHjQlm4QReQmBiNh9A7uPOK/hYlRB1Au5AOCSHp4/8/HU79y23Qs9f0iofZXqyzbZGLCQmZZNLDTW9LDEmku226zNPVYlPkzw2UZMckE4chfcIo8imgkDRFFNOYpMdxPA4UouixvhWhSw1GBXQwu4NGCx5Ux1Cv8f0AFMVHwVqQYRlppcRmYlIxuSAZhhhzQFX1SFXQEhs8otJPOIOOOHSM6mSXFScVgq96Htqu24Je4NTXZm16PkgRWAqyNLgG+Plly4Flu2Sdu1mvndUOQXDHWTUqxL6OIvkO...
706,239
Searching an element in a sorted array (Ternary Search)
Given a sorted array arr[] of size N and an integer K. The task is to check if Kis present in the array or not using ternary search.Ternary Search- It is a divide and conquer algorithm that can be used to find an element in an array. In this algorithm, we divide the given array into three parts and determine which has ...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1617034291, "func_sign": [ "static int ternarySearch(int arr[], int N, int K)" ], "initial_code": "import java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\nclass gfg\n{\n \n public static void main(String args[])throws IOException\n {\n ...
{ "class_name": "Solution", "created_at_timestamp": 1617034291, "func_sign": [ "ternarySearch(self,arr,N,K)" ], "initial_code": "# Initial Template for Python 3\n\nimport math\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n NK = input().strip().split()\n N = int...
eJylVMtqwzAQ7CH9j0HnNHgly498SaEOPbQ+9OLmYEMgCeQjkv/NStu6mFoNm+qgEYjZnR3t6rS4HB4f4noe+PCyNx/ddujNGoaajhA2s4Rpd9v2rW/fXz+H/ufeHJeYMiwoazrPu4bl4EMyC69h5SgDi8koNTwfq+JsDrkuYxGrs0wrUPEZZDX0Ei6wo2AQm+tAKuUVbPY7AqhOBHmajVKD/Ggc6u84XikmlJ/FFc5hsboITiAX8AKFQClQCdQCX3H+9xS6twhWYuqlKLzHUel6m2n7Xm0hF5l0cYyVknBLu02Kn2emLPTsoc4/HsQb...
700,264
K-Palindrome
Given a string s containing n lowercase alphabets and an integer k, a string is considered a "k-palindrome" if it can be converted into a palindrome by removing no more than k characters. Your task is to determine whether the given string s can be made into a k-palindrome or not. Examples: Input: s = abcdecba k = 1 Ou...
geeksforgeeks
Easy
{ "class_name": "GfG", "created_at_timestamp": 1618056987, "func_sign": [ "boolean iskPalindrome(String str, int k)" ], "initial_code": "import java.util.*;\n\nclass Remove_Duplicate_From_String {\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n int T = ...
{ "class_name": null, "created_at_timestamp": 1618056987, "func_sign": [ "iskPalindrome(string, n)" ], "initial_code": "if __name__ == '__main__':\n t = int(input())\n for i in range(t):\n arr = input().strip().split()\n string = arr[0]\n n = int(arr[1])\n ans = iskPalind...
eJytVMtOhDAUdaH/0bCeGPARE7/EZDCmL6A8CpQCLUbjR+iXunNlGUcnTKYjj2k3bdp7c87pOX07//i6ONuMh0+zWD87jBe1dO6B4/kcIkxoEEYs3q7Arc+dFXCoKiiWlDzltdxed33+ag5fVmDYo9OqbWpZibLIeZYmMYvCgBKMIPCuJncTEFMMBXCtlZ6lEkKEMCaE0iAIwyhiLI6TJE3B3WQQEO1NcDMdzp+0SZrxvChFJeumVbo7ItgM1j3pnjbGqFd8BtcdzgGW68lYuk5prYD90W2FZUuF1DXLC1gRg8VA6RRuEM9+ToA30Zau...
704,574
Array's Game
Given an array A of N integers. Two players play a game with the array in turns. The game aims to make the array equal. Players add 1 to any number of the array to increase it by 1(except the maximum number). The player who adds last i.e. the player after whose turn the array becomes equal is declared the winner. If no...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "String arrayGame(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 BufferedRead...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "arrayGame(self,N,A)" ], "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 A = list(map(int, input().s...
eJylU0GrwjAM9qD/I/QssrbrNj2Lf+BdHlgR0R28dKITBfHh0du76P81q644odPFJh0Z9Atf8iWn9vW/07Ln94zB+MCWZrXN2QAY10ahAwcJAkLWBZbuV+k8TxfTbJs/Xv2k88wstPnThh27UMVH2vAA0PtoNqJkCdHBmgc9XM92HmyMDJC9RLSCCGJPhtFyvck9KWRRRHngKeyXh5CUBwWxVxOETIk29/rcl0LHKl1jzTsvsEKJNYV4FcovsP0KKSpI8C/GKy3lxCtrHWFVEcUp4aLERbGLIsrwuQGijA63MjfvXaEpDQUVynYgBHkg...
702,805
Pythagorean Triplet
Given an array arr of n integers, write a function that returns true if there is a triplet (a, b, c) from the array (where a, b, and c are on different indexes) that satisfies a**2+ b**2= c**2, otherwise return false. Examples: Input: N = 5 Arr[] = {3, 2, 4, 6, 5} Output: Yes Explanation: a=3, b=4, and c=5 forms a py...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1729431819, "func_sign": [ "boolean pythagoreanTriplet(int[] arr)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) throws Exception {\n ...
{ "class_name": "Solution", "created_at_timestamp": 1729431819, "func_sign": [ "checkTriplet(self,arr)" ], "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 ob = Solution(...
eJylVMtKBDEQ9KA/4anMeVm685oZv0QwIqIjCEtc3BkQRPAj9H/tjnNYEVkTEwgZMl1dVd3J2/HH2clRGRensrl8MQ95O0/mHIZTZkq5g/WwAUxgi4ABXnb6LYdmBTM+b8fbaby7fpynJfT+ZrMb5fR1he+AXcqWYBl2UDRHcB1iA1Av5GBlMhy80GJXD6LyhILoCSQs0BF6wkCqDVwEN1DjkHJRpyZFcA+VLB7GojfARU3pg6aMXJ/AqXaZzZG2KTIUTQ02e3Waiqt7Sz1O/Kq5Q0QPbmwarQXsXt/Y2OJFfastDfXHGzQ9zT9xiH75...
702,695
Pascal Triangle
Given a positive integer n, return the n**th rowof pascal's triangle.Pascal's triangle is a triangulararray of the binomial coefficientsformed by summing up the elements ofprevious row.The elements can be large so returnit modulo 10**9 + 7. Examples: Input: n = 4 Output: 1 3 3 1 Explanation: 4 **th row of pascal's t...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1731488738, "func_sign": [ "ArrayList<Integer> nthRowOfPascalTriangle(int n)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n // Driver code\n public static void main(String[] args) throws...
{ "class_name": "Solution", "created_at_timestamp": 1731488738, "func_sign": [ "nthRowOfPascalTriangle(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())\n ob = Solution()\n ans = ob.n...
eJztnc2u7kySlRlwIVaNWyhtp51prgSJQgygB0yKHnRLLQESErdA3y/PEz47l5HqfFL3EFG/5zt7v37tzPhZa0VE+n/+63/6X//0r+pf/+6/84d//9/+9F/+8nf/8Pd/+rfbn/Y//+Vq7U9/s/3pb//x7/72P/393/7n//hf/+Hvf3649efZ9qMf174d7Zr96M92XUfv97yP7X6O45zP3bbn6Wdvd5/b8TxP84ez937O1u7tPvp5PmOO7XqOuz/ndW7HdbU+z2Nu57zP/Tn5K/7nvvo8tr7v+/X0wWXvNo9j9m0/9z75l/dxd37/erZ5...
714,007
Minimum Steps Required
Given a string str consisting of only two characters 'a'and 'b'. You need to find the minimum steps required to make the string empty by removingconsecutive a's and b's. Examples: Input: str = "bbaaabb" Output: 2 Explanation: Operation 1: Removal of all a's modifies str to "bbbb". Operation 2: Removal of all remaini...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1676012398, "func_sign": [ "int minSteps(String str)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.io.*;\nimport java.lang.*;\n\nclass GFG{\n\tpublic static void main(String [] args) throws IOException{\n\t\tBuffere...
{ "class_name": "Solution", "created_at_timestamp": 1676012398, "func_sign": [ "minSteps(self, str : str) -> int" ], "initial_code": "if __name__ == \"__main__\":\n t = int(input())\n for _ in range(t):\n str = input()\n obj = Solution()\n res = obj.minSteps(str)\n print(...
eJxrYJmawc4ABhGJQEZ0tVJmXkFpiZKVgpJhTF4iFCRBAYwfk6eko6CUWlGQmlySmhKfX1oC1WMUk1cHlKzVUUAzKIlYiNtoXGajuQ3uWNIdmYgwCMrCaYYxxR7FDsj0PsLfMBbpLscXr4a4LCdZB9BxIPcBQwDEwqndlOjwhXoa2e8QCrfTcEceyDy8SYqgw4lLGFTOArgcTrGr0QMikUDoEEjEuAMHV/ajPELIKZIgFDkOw+oyuLn4sivu5GqBO9axuoKKRRZSQAzqkECzkpKKCsWbhjAziUmDRCTC2Cl6AED0mTE=
703,863
Maximum money
Given a street of N houses (a row of houses), each house having K amount of money kept inside; now there is a thief who is going to steal this money but he has a constraint/rule that he cannot steal/rob two adjacent houses. Find the maximum money he can rob. Examples: Input: N = 5 , K = 10 Output: 30 Explanation: ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1618222083, "func_sign": [ "static int maximizeMoney(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": 1618222083, "func_sign": [ "maximizeMoney(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\n ob = Solution()\n...
eJyNU0tKBDEQdTEHCVkPkkpSqZQnEWxxob1w086iBwRRPIQezJ3HseKIOMIrDaRp6H55n8p73ry+b04+1/mbvVw8xNtlt1/jWYg0LZRSCuMRtyHO97v5ep1vru7269cvnMaalqdpiY/bcAxW1WAbQKsqQ+iBF5MimKeVsFI70VGaqwpjkz1QLgDaqIhgjxQqN8Sau30EWOkabANoIWrMAFrMa4UhNWeeTDk06SheKdy6o/d7rI5wRaoP3DYjTF+TaO1IwaD+I+6E8x5o90J6F3nQQlY2VtfzkXnsnkQ88VaMn3V2Cu2XMtldd3NILeOm...
700,309
Kth element in Matrix
Given aNx Nmatrix, where every row and column is sorted in non-decreasing order. Find the kth smallest element in the matrix. Examples: Input: N = 4 mat[][] = {{16, 28, 60, 64}, {22, 41, 63, 91}, {27, 50, 87, 93}, {36, 78, 87, 94 }} K = 3 Output: 27 Explanation: 27 is the 3 **rd smallest element. Input: N...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public static int kthSmallest(int[][]mat,int n,int k)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nclass KthSmallestElement{\n\tpublic static void main(String[] args){\n\t\tScanner sc=new Scanner(Sy...
{ "class_name": null, "created_at_timestamp": 1615292571, "func_sign": [ "kthSmallest(mat, n, k)" ], "initial_code": "# Initial Template for Python 3\n\n# Driver Code\n\ndef main():\n T = int(input())\n while T > 0:\n n = int(input())\n mat = [[0 for j in range(n)] for i in range(n)]\n...
eJztV9tq20AQ7UOe+w0HPYewl5ldKV8SiEMfEj8UimOoDYGQ0o9I/jdnBE2wpN3YahMwjdcDsnZn5ujMHs/q98nTz69f+s/FD15c3jffV+vtpjlH4xerl29zimZ5t15eb5Y33263m9clvzj5cIpdv0AnBETIYiVFbyl4i3lXxxxM8oIJioSMFh28g2e8AB/hBV7hE9elcvRUCK90cwgO0UEc1FmwoIgKUSivBaFDzJAWicsIJSJ2tjJzsTNn8zZ383ekUYs4+vlJIOlN9vYdc1j2hKU9rWpkGAGu58D1NDgyb4QnBBYjIXrEBPGQBPUs...
714,133
Median of the Subarrays
Given an arrayA[]ofNintegers and an integer M.The task is to count the number of subarrays which have median M. Median of an array is defined as below: Examples: Input: N = 5, M = 2 A[] = {2, 1, 3, 5, 4} Output: 3 Explanation: The subarrays which has median equal to M are [2], [2,1,3] and [2,1,3,5] Input: N = 1, M ...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1677586556, "func_sign": [ "long countSubarray(int N, int A[], int M)" ], "initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*; \nclass GFG{\n public static void main(String args[]) throws IOException { \n Buffere...
{ "class_name": "Solution", "created_at_timestamp": 1677586556, "func_sign": [ "countSubarray(self, N, A, 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().strip().split())\n A = list(...
eJzFVMFOwzAM5YDEbzzlPKE4TpqOAzf+AYkiDtADl7JDJyEhEB8B/4ubdmXt5E7dJq1JUytpXuz37Hxf/t5dXaTn/laMhw/zWq3WtbmBoaIii1BUHgGZvAERuYxLkDULmPJ9VT7X5cvT27ru9rArqq+iMp8LjJBkc8LLZXtMcF6+sbcZTsMMCqazYMGEazaDZORkMdq51u92lhVw4lxBZythNvBk/3sDGFMM3ZQsy9GcbA+JkrJkR1AOWsKl35w45ODEOa9zRyFq5AlI8mTcFKSgMUZdTBZ6PwBTlgJ22lwgoco3ybYRb7sNee9I13gk...
711,095
Eventual Safe States
A directed graph of V vertices and E edges is given in the form of an adjacency list adj. Each node of the graph is labelled with a distinct integer in the range 0 to V - 1. Examples: Input: Output: 2 4 5 6 Explanation: The given graph is shown above. Nodes 5 and 6 are terminal nodes as there are no outgoing edges fr...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1656180881, "func_sign": [ "List<Integer> eventualSafeNodes(int V, List<List<Integer>> adj)" ], "initial_code": "// Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\n// Position this line where user code will be ...
{ "class_name": "Solution", "created_at_timestamp": 1655962218, "func_sign": [ "eventualSafeNodes(self, V : int, adj : List[List[int]]) -> List[int]" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n T = int(input())\n for t in range(T):\n V, E = map(int, i...
eJy9VbtOw0AQpKDgM1auI+Td89kxX0BHi8QhCkhBc6RIJCQE4iPgf9nZ8wkFcOJLFFJEfuzOzM7OJe+nn1dnJ/a5vtSLm5fqMS7Xq+qCKg6xpS7EmvSKSUIUciE6akJsyIfo8cxRW82oWjwvF/erxcPd03o19If4FmL1OqNNzDlxPYDWAGCAMkAlgbYDb4Mvh9uOuIyDFV62Ks8kHc0hqQ+xpxrFHW6bMroO/bvIBLetzVuG7gHyN3pdbov/5f1Ub1x6ay9MTOHiWYjnm+zfErazIzEQDxRGhbdHDnWS6rxVFFrLGuG6OCebahA0jIYU...
702,866
Maximum Sum Bitonic Subsequence
Given an array arr[] of n integers. A subsequenceof arr[] is called Bitonic if it first increases and then decreases. Find the max sum bitonic subsequence. Examples: Input: arr[] = [1, 15, 51, 45, 33, 100, 12, 18, 9] Output: 194 Explanation : Bi-tonic Sub-sequence are : {1, 51, 9} or {1, 51, 100, 18, 9} or {1, 15, 5...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int maxSumBS(int[] arr)" ], "initial_code": "import java.util.*;\n\nclass Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int t = Integer.parseInt(sc.nextLine(...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "maxSumBS(self, arr)" ], "initial_code": "if __name__ == \"__main__\":\n t = int(input().strip())\n for _ in range(t):\n nums = list(map(int, input().strip().split()))\n ob = Solution()\n res = ob.max...
eJy1VMtOw0AM5ID4jtGeK2TvxpuUIzf+AIkiDpADl9JDKlVCSHwE/C92oOIhm1DRRnJe2vGMPet9Pn69ODkar8tzfbl6TPfL1XpIZ0i8WDIRskaxpxBYoyM09jfNkPrNqr8d+rubh/WwRXFDi2V6muF7KgFDg+wWQHP2gGygbBpUgiqARMxUPXyLDnMU5JC3uIKViRtwASvSRAToVnzVWTlV+VzpW9QA3LiSte0KJOs1odWQdw+iJGqRn+azb2pZEfsM6+DqFqKOi6ASqnZerd+mGtNGgsRNVT52k+0iHqsK8J1fzxcnp4SFVgc1Bsvl...
703,081
Word with maximum frequency
You are given a string strthat is made up of words separated by spaces. Your task is to find the word with the highest frequency, i.e. it appears the most times in the sentence. If multiple words have maximum frequency, then print the word that occurs first in the sentence. Examples: Input: str = "the devil in the sky"...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public String maximumFrequency(String str)" ], "initial_code": "// Initial Template for Java\n\n/*package whatever //do not write package name here */\n\nimport java.util.*;\n\n//Position this line where user code will be past...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "maximumFrequency(self,str)" ], "initial_code": "if __name__ == \"__main__\":\n t = int(input().strip())\n for _ in range(t):\n str = input().strip()\n obj = Solution()\n print(obj.maximumFrequency(st...
eJzFVNtOwzAM5YEX/sLqG9KEdmfwJUgEoaw1dGhzujZlIATiI+B/ya1duzVlG5poFNdJk9NzEtufp9/dsxPz3Jwr5/YtmFGSy+AaggEjGSNsdEY8SeYIU06qgR0Yy0gQgu5yJYrOKOhAgC8JhhKje5FLh67hRow+CryB8fUu6wXvHaiQUUtXIo2gwdgvfeMPjB3aqZEZjI29NHZi7JWxva76NQnFI4XiXQhQnWlxZZvq5tViqFgxlkqv9EfO16hWGIdxk8A+oxQT5BLqr4rMjC/0SUnMJIQ8c56d9XJzMPbfDqHfREDxnAt6hB1MhiSR...
710,016
Buy Maximum Stocks if i stocks can be bought on i-th day
In a stock market, there is a product with its infinite stocks. The stock prices are given forNdays, where price[i] denotes the price of the stock on the i**thday.There is a rule that a customer can buy at most i stock on the i**thday.If the customer has an amount ofkamount of money initially. The task is tofind out th...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1650388061, "func_sign": [ "public static int buyMaximumProducts(int n, int k, int[] price)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n BufferedReade...
{ "class_name": "Solution", "created_at_timestamp": 1650388061, "func_sign": [ "buyMaximumProducts(self, n : int, k : int, price : 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(...
eJxrYJmqzcoABhEqQEZ0tVJmXkFpiZKVgpJhTJ6hAogwiMlT0lFQSq0oSE0uSU2Jzy8tgSoBytQBJWt1FDD0GQABSC+YwqHdEJd2kC6w1eRqhdpOunYKtKLYTIm/4UaQbICRAtwUSyAgOd6MUNyvgDsQjHAYYKwA1GyqAIQk2w3WakiubkNKgg3iagxTyHMIJORAFLJZEL+BRWDBS0HSpDClwrXiT6ZYvQixMc8Uhx502xRo43AMk4xINQ3mMIhJJDgqdooeALVcjgI=
702,876
King's War
You are given an array arr[] where each element arr[i] represents the power of the i-th enemy. You can only defeat enemies with the highest and lowest power, and each soldier can defeat only one enemy. Your task is to calculate the number of soldiers required. Examples: Input: arr[] = [1, 5] Output: 0 Explanatation: ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public static int findRequiredSoldiers(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": 1615292571, "func_sign": [ "findRequiredSoldiers(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...
eJxrYJl6l4UBDCKuARnR1UqZeQWlJUpWCkqGMXlApKSjoJRaUZCaXJKaEp9fWgKVNIjJqwNK1uoooOkwAAPS9SlQoJNcV1Jgp5GCsYKJgilOncY4dJoCdRkDdeN2My6d8BBSoCSsjMDQmHTboXZbggEe5xvi8biCMYVej8kDu5+c+KaGVpA3yEmdSMFOKN0QzFdGFLrf2Jhcm2HpPiaGPB9gRCIZXkFLg/jjBJYUY6foAQBVjXcL
704,766
Smallest K digit number divisible by X
Given two integers X and K. The task is to find smallest K-digit number divisible by X.Note: It is given that number of digits in X is always smaller or equal to K. Examples: Input: X = 6, K = 1 Output: 6 Explanation: 6 is the smallest 1 digit number which is divisible by 6. Input: X = 5, K = 2 Output: 10 Expl...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static Long smallestKDigitNum(Long X, Long 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 ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "smallestKDigitNum(self, X, K)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n X, K = map(int, input().split())\n\n ob = Solution(...
eJxrYJn6jpUBDCKeAxnR1UqZeQWlJUpWCkqGMXmGCoZKOgpKqRUFqcklqSnx+aUlCMm6mDylWh0FVB2WIKBgikMXWBaHTkMjYxNTnDrBsrh0GgCBgqEFLq0G6AC/OebEmoM3CIhzjqWlBc4AMaKCl4xJMMMIV7BQK2gNcMcuMdFiRLQjBi/AGU1UiCdo1sMfxqQACzy5FZiwgDETEwPKljgsNMYdnyDNxvh8jNdWA0RpATTJAGwUTsNwuQKPUWSaFRNDSViYGpAcGpYklDQWyEVv7BQ9AAXKpHA=
703,247
String comparison
In a native language, the increasing order of priority of characters is a, b, c, d, e, f, g, h, i, j, k, l, m, n, ng, o, p, q, r, s, t, u, v, w, x, y, z. You are given two strings s1 and s2 and your task is tocompare them on the basis of the given priority order. Examples: Input: s1 = "adding", s2 = "addio" Output: -1...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1708595750, "func_sign": [ "public static int stringComparsion(String s1, String s2)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n BufferedReader br = ...
{ "class_name": "Solution", "created_at_timestamp": 1669977327, "func_sign": [ "stringComparsion(self, s1, s2)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n s1, s2 = map(str, input().split())\n ob = Solution()\n...
eJxrYJl6no0BDCJOABnR1UqZeQWlJUpWCkqGMXl56YlJyQp5QCImT0lHQSm1oiA1uSQ1JT6/tAShqg4oWaujgKq1CgnkpStUoQGc5uniMjARCoCGwZgkOyovHQzz0/MVoMx00h2SDwcKCCY5BiUmIvxUhRFCZAQRDKTDgEIeOiA5yIBxn5Kalp6RmZWdk5uXXlhUXFJaVl5RWaWAKpNfgJAi3RIgSAKC5OTkFCBITVUgKzyT8ENQygFT5EVVOqWpD2fCgeU0argK5jbK3UdMJiaY+PE4vYq6iR9HbiIqXVBgK05TKU1u2AIHu4VU9A02...
703,057
Count the characters
Given a string S. Count the characters that have ‘N’ number of occurrences. If a character appears consecutively it is counted as 1 occurrence. Examples: Input: S = "abc", N = 1 Output: 3 Explanation: 'a', 'b' and 'c' all have 1 occurrence. Input: S = "geeksforgeeks", N = 2 Output: 4 Explanation: 'g', 'e', 'k' and...
geeksforgeeks
Easy
{ "class_name": "Sol", "created_at_timestamp": 1615292571, "func_sign": [ "int getCount(String S, int N)" ], "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 \n Scanner sc = new Scanner(...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "getCount(self,S, N)" ], "initial_code": "# Initial Template for Python 3\n\nt = int(input())\nfor tc in range(t):\n s, n = input().split()\n s = str(s)\n n = int(n)\n ob = Solution()\n print(ob.getCount(s, n))\n...
eJxrYJkqzsoABhECQEZ0tVJmXkFpiZKVgpJhTF6igqGSjoJSakVBanJJakp8fmkJQrIuJk+pVkcBTUcieXqMcegxwKUnKTklNS09IzMrOyc3L7+gsKi4pLSsvKKyCqf1Rma4zUJG5LgFRb8pDv3GOPRXYQEkByJ2QwxI9kpSIggnJSoYkRMjqSnJeLSakOB28lyPcAJ5zifP/aAQi4mBhFsSeQGHIylTJ3WCAoW8IAEh8hN2YkoSuVaDigSqpWrs6YsIg2Kn6AEA0lW6kw==
703,033
Fighting the darkness
Given an array arr[]representing the size of candles which is reduced by 1 unit each day. The room is illuminated using all the the present candles. Find the maximum number of days the room will stay illuminated (at least one candle is having size greater than 0) Examples: Input: arr[] = [1, 1, 2] Output: 2 Explanat...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "long maxDays(int arr[])" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass Main {\n\n public static void main(String[] args) throws IOException {\n ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "maxDays(self, arr)" ], "initial_code": "if __name__ == \"__main__\":\n import sys\n input = sys.stdin.read\n data = input().splitlines()\n\n t = int(data[0].strip())\n\n for i in range(1, t + 1):\n arr = ...
eJydU0EKwjAQ9NCHDDkX2aRNbXyJYMWD9uCl9lBBEMVH6Ge8+TO3VaRCNyWGEgLJDDOz02t0f0aTbi0efFie1K6qD42aQ+miIhVDlce63DTldr0/NJ8rKqpLUalzjN/3mojw3QRweyXhYZAghUWGGXI45hFZRA0MyxmeMU3KdAY6lMMS5E8gs+OmxvRYgcEwLmNP/4QRimi1Wk5Pa+gEmg8OhkU7gcg4gSghmLYHkCQkvhaRZ2ie/pC/doHz9sxanva7/eHd7/IKj6pf9hyecqW5ZL790dmucaJdPQSVXg9mIucxqAq9/nQSx4JZ3aYv...
714,254
Nearest smaller tower
Given an array where each element (arr[i]) represents the height of the tower. Find for each tower, the nearest possible tower that is shorter than it. You can look left or right on both sides.Note : Examples: Input: arr[] = {1,3,2} Output: {-1,0,0} Explanation: For 0th Index : no tower is smallest, so -1 . For 1s...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1678884657, "func_sign": [ "int [] nearestSmallestTower(int [] arr)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.io.*;\nimport java.lang.*;\n\nclass GFG{\n\tpublic static void main(String [] args) throws IOExceptio...
{ "class_name": "Solution", "created_at_timestamp": 1678884657, "func_sign": [ "nearestSmallestTower(self,arr)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n for _ in range(int(input().strip())):\n N = int(input())\n arr = [int(i) for i in input().s...
eJzVV81uFDEM5sAdceNozblTxXYyPzxJJRZxgD1wGXrYSkgIxEO074vtDPvTidMu3S2w8XhnxxnH+fLZyf58effm1Qv7XL2Wm3ffms/T9c2meQsNriYMqykBBiio5gKa9dfr9cfN+tOHLzeb+a0WIYAoUhVVdaoGWE0/VlPz/QLuDZHkkt4snZNcLPe73x30tXFyR+kk/m2QUaNDBBQn7A1JQS9A6TwA9oAdoMwo6iv6Ih440efJ+vTWf3QCOgj6dyht1ZcXn0Cy8DT7MH+jPOzFuMDLC23cYrXz6k8QKK9gABJNQC6SHJQjkCf5ZOUC...
703,779
The Nth Fibonnaci
Given a positive integer N, find the last digit of the N**th term from the Fibonacci series. Examples: Input: N = 5 Output: 5 Explanation: 5th Fibonacci number is 5 Input: N = 14 Output: 7 Explanation: 14th Fibonacci number is 377 It's last digit is 7 Constraints: 0 <= N <= 1000
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int fib(int N)" ], "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 main(String args[])thro...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "fib(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.fib(N))\n ...
eJxrYJnqx8IABhHuQEZ0tVJmXkFpiZKVgpJhTJ6Bko6CUmpFQWpySWpKfH5pCVTKICavLiZPqVZHAVW9IQ71hrjU47LAFKcGMnSQqsXS0hKHDjMcOkxJtsPIlFQdxsbGOHRY4NBhYWFBoj8MSY4QU9wxgjWRGED8jjfMcKUWA7wuxKrLgGz7UHVSy5QYVIE8MkLAAqLVAkjHkJzdIHrJCXi4tUTYGztFDwBAUldc
703,451
Total count
You are given an array arr[] of positive integers and a threshold value k. For each element in the array, divide it into the minimum number of small integers such that each divided integer is less than or equal to k. Compute the total number of these integer across all elements of the array. Examples: Input: k = 3, arr...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1618835072, "func_sign": [ "int totalCount(int k, 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...
{ "class_name": "Solution", "created_at_timestamp": 1618835072, "func_sign": [ "totalCount(self, k, arr)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input())\n\n while t > 0:\n k = int(input())\n arr = list(map(int, input().split()))\n...
eJy1VElOw0AQ5IDEN0o+R8gzns28BAkjDuADF5NDIkVCIB4BP+LGp+huO+AgtxcglXQpUjzVy1T75fTt4+xEcPlOP64es/tmvd1kF8hM1Zicg4GSgcRAZCAw4BlwDBQMWAYMo2qyFbJ6t65vN/XdzcN202kHknRV80wPPK3wI+mRcnpW81pSyXikzDzGway+SwqLAg4eAREJJUxXgi5pFcnu2LfkvjNFKOoDYTE+TmEoqMu8oHAULBsoIkWi0Au1eu8cGP3q7RtFNbYTMDI+K1wIO2EvHISjqt79O24UDHzGR60WbXregxUuhJ2wuARB...
701,264
Spirally traversing a matrix
You are given a rectangular matrix, and your task is to return an array while traversingthe matrix in spiral form. Examples: Input: mat[][] = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15,16]] Output: [1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5, 6, 7, 11, 10] Explanation: Input: mat[][] = [[1, 2, 3, 4], [5,...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1729793602, "func_sign": [ "public ArrayList<Integer> spirallyTraverse(int mat[][])" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n Scanner sc = new Scan...
{ "class_name": "Solution", "created_at_timestamp": 1729793602, "func_sign": [ "spirallyTraverse(self, mat)" ], "initial_code": "if __name__ == \"__main__\":\n import sys\n input = sys.stdin.read\n data = input().split()\n\n t = int(data[0])\n index = 1\n for _ in range(t):\n r = ...
eJyllU1OhEAQhV0Yz/HCemKqfwFPYiLGhbJwg7NgkkmMxkPoMdx5QKsb4jBI0T0K4Sfpmq8f9apq3s4/vi7O4nH9yS83z8Vjt931xRUK1XQKfHNNV2xQtPtte9+3D3dPu36M4JVXXnzZYP4zXlEETTAES3AkMuZhi0AXdHheLfmq+KopbCBTPaEkVISaEOMWsRo6iOWbgZUVQsPCiAwTGeFh4eBXOQaeY6zAMsd6UjAbYZIw81tYiQp1Ul/NUSXDJXetCGYvFZeMzthC6RhKw06opEoiCtYLOLH81kojJ10nZczFfHn+DsnXo37I6oaV...
703,252
Meta Strings
Given two strings consisting of lowercase english alphabets, the task is to check whether these strings are meta strings or not. Meta strings are the strings which can be made equal by exactly one swap in any of the strings. Equal string are not considered here as Meta strings. Examples: Input: S1 = "geeks", S2 = "keeg...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "boolean metaStrings(String S1, String S2)" ], "initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*; \nclass GFG{\n public static void main(String args[]) throws IOException { \n Buffere...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "metaStrings(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 = input().strip()\n S2 = input().strip()\n ob...
eJztWM2S2yAM7qHv0Gsm551Os9u9dPognSmdDhayTYKFA9hx0mmnD9G+byFOnGx+nc3fpLs6BCEkkNEHEvn99u/nd2+m9OXRM19/dCXlhet+6nQfGPEIBCMBEZ/zPBKw4CHu3nW6WOUIDsV3XbiZ7QdGvxj1pr813/1511ma/KM351EEIARiHC96cYxYL+AbjJNUhrEwGsbBLy48BS5IZppxwijiU2anQ8u/vU1uPTLK0HHrjKTEMiI0zvIssc67UUvD+LIWI9BZrrACboPnyx07kg5SRm4kLTjPcJWnPEI35xy29neH1w/1Fs0oagga...
703,443
Maximum average subarray
Given an array arr of sizen and a positive integer k, find the subarray of length k with the maximum average. You need to return the starting index of the subarray. If there are multiple subarrays with the same maximum average, return the smallest starting index. Examples: Input: k = 4, n = 6 arr[] = {1, 12, -5, -6, 50...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "int findMaxAverage(int[] arr, int n, int k)" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\npublic class GFG {\n public static void main(String[] args) throws Exception {\n ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "findMaxAverage(self, arr, n, k)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n k = int(input())\n n = int(input())\n arr = li...
eJyVVM0OgjAM9qDvsewMBpG/+SQmYjwoBy+TAyQmRuND6NGbD+paQUTXWWnTNOz72vKN7Ty83kcDfOY3kywOcqvLupIzISe5bjwIAukJWezLYl0Vm9WurlqMWRK5PuVaHj3RJ0fosUAj+M0qVWKK/rsAQQ8N11QQjRElYI0oEMPHPwUQPsY/UpdkdhoxBY4AowiHORpawdZmIeqd5lop9URB8j5su/DSxu/em5BBSCEkEGIIEYQphNA1Zq8lDkcVoHTKzI63u8WxX5vUN6KpQsfvbzRwJUQ7Lt06hOtn+4QaCbtzweYkbGTERlJSWJDU...
703,315
K closest elements
Given a sorted array of unique elements in increasing order, arr[] of n integers, and a value x. Find the K closest elements to x in arr[].Keep the following points in mind: Examples: Input: n = 13 arr[] = {12, 16, 22, 30, 35, 39, 42, 45, 48, 50, 53, 55, 56} k = 4, x = 35 Output: 39 30 42 45 Explanation: First clos...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "int[] printKClosest(int[] arr, int n, int k, int x)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\npublic class GFG {\n\n public static void main(String[] args) throws Excepti...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "printKClosest(self, arr, n, k, x)" ], "initial_code": "if __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n n = int(input())\n arr = list(map(int, input().strip().split()))\n k, x = list(...
eJydk0Fu2zAQRbNo7vGhdVhwSA4p5SQFoiKL1otu1CwcIEDQoodIjpldD5A/ZGDAQScQKluWIM9/8+dT/PPp+e/lRT++vPDm5nH6sd3dH6drTLJuKa6bIEPRsEAEkiEKaZAFSZAykiI1pAWZhRlZkRvysm58TvV0henwcHf4djx8v/15f3xjU2uEbCgS1u03S39d4by9EBBSRGDPILwqIr3wToxO5boV+F3UFKbj6bTIfcLC+YxKP7UbS32uuQ9VbKISUTJKRVmgCarQGVVQC2pDi2gZraItmBNmxTyvW4X63gaHQKJIJs1xaEOezYwc...
703,757
Check for Power
Given two positive numbers X and Y, check if Y is a power of X or not. Examples: Input: X = 2, Y = 8 Output: 1 Explanation: 2 **3 is equal to 8. Input: X = 1, Y = 8 Output: 0 Explanation: Any power of 1 is not equal to 8.
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static Long isPowerOfAnother(Long X, Long Y)" ], "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 ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "isPowerOfAnother(ob,X,Y)" ], "initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n X, Y = map(int, input().strip().split(\" \"))\n ob = Solut...
eJylk0EKwjAQRV30IEPWRTLTpKGeRLDShUZwE7tIoSCKh9D7mtpCcZHixKwC4YXJfz+P7HXKVp+1bcJmdxVn13ZebEBg7QogUzuRg7B9aw/eHptL5+fzezi85fANaUDSbAoloJSSzVHASLExA6piQxUY4lMlFCUbUkCaTyGG7DElw7hmuRT8rDuuIHbBlOYgI0EeJPSSlooZGzO8byzmP2wSjGHglInHL8EXMtSA34NJo/nB4/65fgPaoV7L
703,024
Nuts and Bolts Problem
Given a set of nnuts& bolts.There is a one-on-one mapping between nuts and bolts. You have to Match nuts and bolts efficiently. Comparison of a nut to another nut or a bolt to another bolt is not allowed. It means the nut can only be compared with the bolt and the bolt can only be compared with the nut to see which one...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1618056386, "func_sign": [ "void matchPairs(int n, char nuts[], char bolts[])" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) throws Exceptio...
{ "class_name": "Solution", "created_at_timestamp": 1618056386, "func_sign": [ "matchPairs(self, n, nuts, bolts)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n n = int(input())\n nuts = list(map(str, input().stri...
eJzNVE1Pg0AQ9eDBnzEs4IE0JviNF/ZnmDjWg3LwsvZAExOj8UfUk3/WmV0qUHa2WIOxoenQmXnvDfPY9/2Pz4M9+7leUXDzoh7NYlmrK1A5Gro0XWoGqnpeVPd19XD3tKybAg2Uo+8bGvU6g37rMZoI5mjmEAntlAZbJEGcoDmEFDI0GVAgwKSUywhi/euFOkWTgIbSKUookIayOaupjbyQZ6xdE2UMKSvkm1hUGXGOirUduY290Ocsksl5/MRJ55D+FFXz+K3y7p2X4gJNDK4u40o0pR3GMkIs0PRaYANCorp0E68rtdtBhyzgkF4b...
703,179
Maximum Sum Path in Two Arrays
Given two arrays arr1 and arr2. First sort both the arrays. The arrays may have some common elements. Find the sum of the maximum sum path to reach from the beginning of any array to the end of any of the two arrays. You can start from any array and switch from one array to another array only at common elements. Exampl...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int maxPathSum(int[] arr1, int[] arr2)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass Main {\n public static void main(String args[]) throws ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "maxPathSum(self, arr1, arr2)" ], "initial_code": "# Initial Template for Python 3\n\nimport io\nimport sys\n\n# Contributed by : Nagendra Jha\n\nif __name__ == '__main__':\n test_cases = int(input())\n\n for cases in ran...
eJytlM1qwkAUhbsofY7DLIuU+cmdaJ9EqKWLNgs30UUEobT4EPZ9vUmcYDFHSfTOIvP7zZlzL9k9/rmnhybmz9p5+zbLcr2pzCuMW5TONtF1zASm2K6Lz6r4+lhtqrQzbftdlOZnAgKxuAXTne6IV3D+sip4BGQQROSYYqa0eranEb4IfTC8RbDILKSGCrwgCDLRMXt8zpTOmlADyMm0zsxXMbUaxUtjGZy0c56KmV63TWn6CTpk/jjmj8WxnXQJg8sImrkc+myvMqIm0DFG4BV1bPcqc+r0eJvPqvO8PFtVNAvtqht40dh7LiXs9oz1...
703,187
Convert an array to reduced form
Given an array with Ndistinct elements, convert the given array to a reduced form where all elements are in range from 0 to N-1. The order of elements is same, i.e., 0 is placed in place of smallest element, 1 is placed for second smallest element, andN-1 is placed for the largest element. Examples: Input: N = 3 Arr[] ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "void convert(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 Buffere...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "convert(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 arr = list(map(int, input().strip().split()))...
eJy1lMFKxDAQhj3oeww5b2WSNG3XJxGMeNAevMQ9dEEQF8GbZ31f/0krWJZJq2KbGQqdfDOTf9qX04+3s5N8Xb7i4erJ3KfdfjAXZGxMspjNhkz/uOtvh/7u5mE/TO+ZYjrEZJ43NN/lYmKy6i5b2IdspOWzpGasY6oCU+VgVqyQ3JHXMEEKn+4FQq0xmtwEkxPnxdXigriGC4f5xQ0a2aPJjEbsEkhBtKDgfQ0LtCWnMDxSjDGNzuqwUEw79iUNSqfSsvRO+ty0oAbwPdgFTS2LocqOZjsU6lGcTg75IP8q9Dit3Y/HtSqIdxS6Lm5S...
705,423
Largest square formed in a matrix
Given a binary matrix matof size n * m, find out the maximum length of a side of a square sub-matrix with all 1s. Examples: Input: n = 6, m = 5 mat = [[0, 1, 1, 0, 1], [1, 1, 0, 1, 0], [0, 1, 1, 1, 0], [1, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]] Output: 3 Explanation: The ma...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int maxSquare(int mat[][])" ], "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 Scanner sc ...
{ "class_name": "Solution", "created_at_timestamp": 1712733819, "func_sign": [ "maxSquare(self, mat)" ], "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 _ in range(n):\n ma...
eJztV81Kw0AQ9uAD+AjLnovMJhTBJxGMeNAcvMQeUhCkxYfQd/DmK5qfLd3dmW+2EalE2i0k3c7vNzP7JW/nH18XZ8Pn5rO7uX21T81q3dprY13VODKOuovprn75u6qheKO/6yXZ2ksGJkZJigwg9UAi3IxUw03mKPXv7MLY+mVVP7T14/3zuvUJl1WzrRq7WZgEhaVxy711SgwS8kNxGLKuiFEMTIRWajxJXMQaBca0BaxEAHnNgEjom4uwkpH0N4Q1LInoW/S5E5jYBAWZgnWoXBIKE1MiwCmCOmSF9LRFdPUoE5wzVsUJlGOkvBDK...
703,535
Good or Bad string
In this problem, a String S is composed of lowercase alphabets and wildcard characters i.e. '?'. Here, '?' can be replaced by any of the lowercase alphabets. Now you have to classify the given String on the basis of following rules: Examples: Input: S = aeioup?? Output: 1 Explanation: The String doesn't contain more...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int isGoodorBad(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 BufferedRead...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "isGoodorBad(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\n ob = Solution()\n print(ob.isGoodorBa...
eJxrYJn6m4UBDCK+ABnR1UqZeQWlJUpWCkqGMXmJqZn5pdgI+5g8JR0FpdSKgtTkktSU+PzSEqgug5i8OqBkrY4CqlFJySlAZA/EJGtNxG2bIQ4tpOtIBLosNS2dDI2pmfbkBAgoKFJJ1wZypz054W+fbJ9ChiuBgKwIIy8SIBpRjCDdFJTYJCLd4UlE0HhCMRFPpOEyCRr4MYakhiQur8QQTkC43EJ2wivFWhiQm35jkIxETtboxpMRYpA0S2z4xE7RAwCikqvz
705,736
Count all possible paths from top left to bottom right
The taskis to count all the possible paths from top left to bottom right of a mXn matrix with the constraints thatfrom each cell you can either move only to right or down.Example 1: Examples: Input: m = 2, n = 2 Output: 2 Explanation: Two possible ways are RD and DR. Input: m = 3, n = 3 Output: 6 Explanation: Six p...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1616523076, "func_sign": [ "long numberOfPaths(int m, int n)" ], "initial_code": "//Initial Template for Java\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": 1616523076, "func_sign": [ "numberOfPaths(self, m, n)" ], "initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n m, n = input().split()\n m = int(m)\n n = int(n)\n...
eJytks9KBDEMxj3sg4SeF0nSpG18EkHFg87By7qHWVgQwYfQR/LmQ9kp40FMZ3HYQv8c8kv6fcnb5uNrc9HW9Wd93LyEp93+MIYrCHS7I0SoO2whDMf98DAOj/fPh3EOSIZcNMUaGF638BtVBO2BnLIwcxQPzAqsPZAiCiGzB7JCXgWaAXc4M7cSmP0LaD52CNc9WrDdBQqC9QDNmqOiFVc8QlkF1ga3s9tlX1ibqA4RTYuKcnRNXxqMQkVIk7lkkzjVXnJVLalmstyv/fP9eWS6maRWS5LcTBN4YiASxVIo9btVbzyHlnPo8Z2ZJa42...
700,241
Max sum path in two arrays
Given two sorted arrays of distinct integers arr1 and arr2. Each array may have some elements in common with the other array. Find the maximum sum of a path from the beginning of any array to the end of any array. You can switch from one array to another array only at the common elements. Examples: Input: arr1 = [2, 3...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1617225608, "func_sign": [ "public int maxPathSum(List<Integer> arr1, List<Integer> arr2)" ], "initial_code": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n ...
{ "class_name": "Solution", "created_at_timestamp": 1617225608, "func_sign": [ "maxPathSum(self, arr1, arr2)" ], "initial_code": "if __name__ == \"__main__\":\n t = int(input().strip())\n for _ in range(t):\n arr1 = list(map(int, input().strip().split()))\n arr2 = list(map(int, input()...
eJytVUFOwzAQ5IDEN0Y5cCpo1/Y6MS9BoogD9MCl9NBKSAiJR8B/2bWpaIvdkkKlWLWSzM7Mzjpvpx8XZyf5d32uf25eusf5YrXsrtDxdM4ER/CEQBDSvcAJvCAIRKbzboJu9ryY3S9nD3dPq+X6zd7uvU6wgwYPQY8E1p1DQMQArcGuCRVcFYmMmDHLpHSjlzeGDZg+36swMiS9yqLPSOYj621LIDNxDXD9uqNslJHKLn4Zl40Me4xLDZrfxoF95teD046J4ACO4EHL76HeLNFneMVOcH4D2xmqKQpN1FRtU8WNYkAJE5wWDaosaunB...
703,254
Min Manipulations to make Strings Anagram
Given two strings in lowercase, your task is to find minimum number of manipulations required to make two strings anagram without deleting any character.If two strings contains same data set in any order then strings are calledAnagrams. Examples: Input: S1 = "aba", S2 = "baa", N = 3 Output: 0 Explanation: Both the st...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "int minManipulation(int N, String S1, String S2)" ], "initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*; \nclass GFG{\n public static void main(String args[]) throws IOException { \n ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "minManipulation(self, N, S1, S2)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input().strip())\n S1, S2 = input().stri...
eJyllN8KgjAUxr2w9zjsWsKJVvQkQYtwbrNulhcKURQ9RD1u0PyzMGLa1kH0Qr5zfuf7nDf/4U+8plZP3/PWZ7SXRVWiJSBMpLpSSFEAiB8LnpWcbQ9V2b0PibwSiS4BfIoiJaKQMYMsMshmtSxjXIDgLKO2U5X81BS0D0t5oqbXBbQugzgxiBcaPd/BLnfCx2EH0KMYQsGmRnHbB+qbJUPcrgEO+HPtgEpPcG5ugIexW26n7OV4+KbhOnzqlH63u1DL6/D/MwEIGTBhdAm3Lb48tDXxfQAdT2D/w7XhGf0h/Aq0uU9fChOyAQ==
703,743
Adding Array Elements
Given an arrayArr[]of size Nand an integerK, you have to choose the first two minimum elements of the array and erase them, then insert the sum of these two elements in the arrayuntil all the elements are greater than or equal to K and find the number of suchoperationsrequired. Examples: Input: N = 6, K = 6 Arr[] = {1...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1617639859, "func_sign": [ "int minOperations(int[] arr, int n, int k)" ], "initial_code": "//Initial Template for Java\n\n\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) throws Exception {\n ...
{ "class_name": "Solution", "created_at_timestamp": 1617639859, "func_sign": [ "minOperations(self, arr, n, k)" ], "initial_code": "if __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n n, k = list(map(int, input().strip().split()))\n arr = list(map(int, input().strip().spli...
eJylVEFOwzAQ5IB4x8jngnadrOPwEiSCOEAOXEwPqYSEQDwC3siNN2AnpW0ga5o2a8U+2OPZmfW+nX58nZ3039VnXFw/m4ewXHXmEoabIGBqAsOiQAkxC5j2adnede397eOqW28sm/DaBPOywPh0BZYmePA2FIRzViCYYKmf0mocClatQHnYyMbSLh2VUKWAOEiiE3UZDQVFtKxkgEnJoSCUBJkKBZYLBTclRxu5DhralZqqbOH6EpmKstbgNL89qiiaRD0mxszys0ll6lVZa0yRKyqCJ9SUnItbCkEZNwqcxLvhBbVg5Mz2lELAan7s...
700,816
Count the Specials
Given an array arr[] (may contain duplicates) and a positive integer k, your task is to count the number of elements whose occurrence is exactly equal to the size of array arr[] divided by k times. Examples: Input: k = 2, arr[] = [1, 4, 1, 2, 4] Output: 2 Explanation: In the given array, 1 and 4 occurs floor(5/2) = 2...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1722624894, "func_sign": [ "public int countSpecials(int k, List<Integer> arr)" ], "initial_code": "// Initial Template for Java\nimport java.util.*;\n\n//Position this line where user code will be pasted.\npublic class Main {\n public static void mai...
{ "class_name": "Solution", "created_at_timestamp": 1722625571, "func_sign": [ "countSpecials(self, k, arr)" ], "initial_code": "from collections import Counter\n\n\ndef main():\n t = int(input())\n while t > 0:\n t -= 1\n k = int(input())\n arr = list(map(int, input().split()))...
eJytU8EOgjAM9aD/0exMDGxMxC8xEeNBOXiZHCAxMRo/Qk/e/FI3YOgkhVBte1gC7+31tbuO78/JqIzlQx9WJ7ZXWZGzBbAgUab8MhLFPGDpMUu3ebrbHIr8/ddFfzx70IYOB+l7ArDJbaI8PsIjDQ0HASFIFCwRsNB4kB1A7FbRuAVxGUA1L/rQDzOIUIIIIZgnKgQnB3fjzqLJ4Tyy9lO7YUvWxX1bsiqK5/WwFP/XuGJUhehYdg0UpIfyvfM90ohPwmE16/GTzACq6tNPekPOWCvB1GbtAWduguKJWW1Cg9DSAb0trm/TF5PDpNY=
700,555
Counting Sort
Given a string arr consisting of lowercase englishletters, arrange all its letters in lexicographical order using Counting Sort. Examples: Input: N = 5 S = "edsab" Output: abdes Explanation: In lexicographical order, string will be abdes. Input: N = 13 S = "geeksforgeeks" Output: eeeefggkkorss Explanation: In le...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public static String countSort(String arr)" ], "initial_code": "import java.util.*;\nimport java.lang.*;\n\nclass CountSort\n{\n public static void main (String[] args) {\n Scanner sc = new Scanner(System.in);\n ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "countSort(self,arr)" ], "initial_code": "# Initial Template for Python 3\n\nimport atexit\nimport io\nimport sys\n\n_INPUT_LINES = sys.stdin.read().splitlines()\ninput = iter(_INPUT_LINES).__next__\n_OUTPUT_BUFFER = io.StringI...
eJzNV9uO0zAQ5YFnvqHK8wr1sl0hvgQJIxQ7zj2Tm+M4QSA+Aj6PNz6EcTZLy268SZoGmL40bZJzZs6Zsf315fefr1508e4Hfnn/yQogq4T1dmMdCOzvCOQ1L0RTBWlml47r+WEUt4pJCgmB3Z5AAlQy1cZR6HsEjlsCtm1TShljjuNwzl3X9TzP9/0gCMIwjKIojuMkSaybjcVVxpngzse0Ej2sTZnDESdAoATSLC9KUclaNS2BLwQo6ygkINX9DxPRunutzzebswyR/QH5dtRdp7RPqfZJYYZHAm2rFGNSUgpwOW+kiA8DSKlU2w7R...
703,368
Longest Common Increasing Subsequence
Given two arrays, arr1[] and arr2[], find the length of the longest common increasing subsequence(LCIS). Examples: Input: arr1[] = [3, 4, 9, 1], arr2[] = [5, 3, 8, 9, 10, 2, 1] Output: 2 Explanation: The longest increasing subsequence that is common is {3, 9} and its length is 2. Input: arr1[] = [1, 1, 4, 3], arr2[] ...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int LCIS(int[] arr1, int[] arr2)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass Main {\n public static void main(String args[]) throws IOException {\n BufferedReader read = new BufferedRe...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "LCIS(self, arr1, arr2)" ], "initial_code": "if __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n arr1 = list(map(int, input().strip().split()))\n arr2 = list(map(int, input().strip().split()...
eJzNVs1u1DAQ5tAjDzHKuUIe/yY8SSUW9QB74BJ62EqVEBIPAS/ZG2/AN5+TdOkmkF1Kt9baa3s+j+ebGTv+dvHj5+tXLFf36Lz70nzqb253zVtp0qZXJ95JcBKdJLfps/3ZIFCgmCqSJIgSaz0vKlmKtJse0wbb9KaD4BZCA3WAtWIbYKi/TTj0W6zPkMSqz2Ae3YgpqgZEXXMpzfbuZvtht/14/fl2N1htaOyI3dlpvl7KHqdoO5hRRsGYwChNdcKnOhnSKMDeahwURoJAEYWdsAVWJfFFfAdQ4GwitFCmFCTzDzXXLfbHiWyAs66S...
703,492
A difference of values and indexes
Given an unsorted array arr[ ] of size n, you need to find the maximum difference of absolute values of elements and indexes, i.e., for i <= j, calculate maximum of | arr[ i ] - arr[ j ] | + | i - j |. Examples: Input: n = 3 arr[ ] = {1, 3, -1} Output: 5 Explanation: Maximum difference comes from indexes 1, 2 i.e |...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1617564362, "func_sign": [ "public static int maxDistance(int arr[], int n)" ], "initial_code": "//Initial Template for Java\n\n//Initial Template for Java\n/*package whatever //do not write package name here */\n\nimport java.io.*;\nimport java.util.*;\...
{ "class_name": "Solution", "created_at_timestamp": 1617564362, "func_sign": [ "maxDistance(self, arr, n)" ], "initial_code": "# Initial Template for Python 3\nfor _ in range(0, int(input())):\n n = int(input())\n arr = list(map(int, input().strip().split()))\n ans = Solution().maxDistance(arr, n...
eJydlc1OAkEMxz2Y+BrNnhmzbWfYXZ/ERIwH5eAFPYAxMRgfQt/XdlpAgQJhYD/p/Npp/1O+Ln+WVxd13L7Jzd1H8zx7XcybG2hwMsNWjzogDXVA8Ue/InEuY0jjkpkQ3CitZrXQ1dGMoJm+v04f59Onh5fF3H1Qteoms8/JrFmO4L97EvcFxoCQCDrogSFlGABbIEgMiOJeIgGU+yy+ktiWwBVz4KWIF4sXajjA9Zzrua4Sxrbkrl56T4ct37Ng8xMaAQ2B2d8aBR2DxkEDoYGSpQLISWQkMhIZiYr/aCQyEBmIHMQGYgexL8pA7CGx...
700,361
Josephus problem
A total of n people are standing in a circle, and you are one of them playing a game. Starting from a person, k persons will be counted in order along the circle, and the k**th person will be killed. Then the next k persons will be counted along the circle, and again the k**thperson will be killed. This cycle will cont...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1617189575, "func_sign": [ "public int josephus(int n, int k)" ], "initial_code": "/*package whatever //do not write package name here */\n\nimport java.io.*;\nimport java.util.*;\nclass Recursion {\n\tpublic static void main (String[] args) {\n\t\tScann...
{ "class_name": "Solution", "created_at_timestamp": 1617189575, "func_sign": [ "josephus(self,n,k)" ], "initial_code": "import math\n\n\ndef main():\n T = int(input())\n\n while T > 0:\n nk = [int(x) for x in input().strip().split()]\n n = nk[0]\n k = nk[1]\n\n print(Solu...
eJydk7EKwjAQhh36IMfNRXKJIPEJ3FwFKw6awSV2SEEoig+h72taW8ThT4mZAsmf/7/vLo/itSlm/dqu42bX8tnXTeAVsVReSLgkdtfaHYM7HS5N+B7eK8+3kn4VWkGJVkAjpFW+DdRopMHJoEL/kQtILKreklhkg5IJxiwIsyGTXX82MrGSKGcJRyBCGPCN3VXolQWubyqAgRPYuebOunSpe18v6cjxJnYefkAM4LMTdNhSvoiV/uDObu/IeILv/jl/A9c8UuI=
703,298
Rotate Array by One
Given an array arr, rotate the array by one position in clock-wise direction. Examples: Input: arr = [1, 2, 3, 4, 5] Output: [5, 1, 2, 3, 4] Explanation: If we rotate arr by one position in clockwise 5 come to the front and remaining those are shifted to the end. Input: arr = [9, 8, 7, 6, 4, 2, 1, 3] Output: [3, 9, ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1617908604, "func_sign": [ "public void rotate(int[] arr)" ], "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 {\...
{ "class_name": "Solution", "created_at_timestamp": 1617908604, "func_sign": [ "rotate(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 ...
eJztmc1u3DYURrvogwizDgKR/PijPEmAuOii9aIbNwsHCBAkCLLLPnnffDxpi9a1nJlkZHtsWgAxsH0k8t5zOVfS+58/f1x+4uf5B3948Wb3x8XLV5e7Z9MunF2Euf9MS/9hbIyVsTBmRjEmxsgYGGEbbINtsA22wTbYBttgG2yDrbAVtsJW2ApbYStsha2wFbbAFtgCW2ALbIEtsAW2wBbYDJthM2yGzbAZNsNm2AybYQUrWMEKVrCCFaxgBSvYBJtgE2yCTbAJNsEm2ASbYCNshI2wETbCRtgIG2EjbIQNsAE2wAbYABtgA2yADbAB...
701,248
Level of Nodes
Given an integer x and an undirected acyclic graph with v nodes, labeled from 0 to v-1, and e edges, return the level of node labeled as x. Examples: Input: x = 4 Output: 2 Explanation: We can clearly see that Node 4 lies at Level 2. Input: x = 1 Output: 1 Explanation: Node 1 lies at level 1, immediate after No...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "int nodeLevel(int V, ArrayList<ArrayList<Integer>> adj, int X)" ], "initial_code": "import java.util.*;\nimport java.io.*;\nimport java.lang.*;\n\nclass DriverClass\n{\n public static void main (String[] args) {\n Sc...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "nodeLevel(self, V, adj, X)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for i in range(t):\n V, E = list(map(int, input().strip().split()))\n adj =...
eJztV8tu1EAQ5MCZb2j5HEXTj5mx+RKkGHEIe+Di5LCRkBAI5ZY7+V+62qsNeQybzdNIrHZnLdlTVV3d7rZ/vr28ePcmPh/O/eDoW/dlOj1bd++p43HiRMM4JcIhCRYdJyXDkscpU8FSx6lSP049LvZvd0Dd6uvp6ni9+vzp5Gy9wfNrf/jJ7wd0naQHQAK8ANkAWmZK3RKBo4lcG8iciW2jP231M1gEsAIqA7ZBf4F+Z07QxKGMJUxgnf98I34NGdaQIb5z2CVDIUMhwyDDQkYOGTlklFBRQkQlzrGWEFlj9a1DEOHcnhJZgukeEq+c...
703,461
The Optimal Selection
Given an array arr[] of positive integers, you need to select all integers from the array in an order that maximizes the total points. For each selected integer, the points earned are equal to the integer's value multiplied by the number of integers already selected before it. Calculate the maximum points possible and ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public static int Selection(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": [ "Selection(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 ...
eJztmEtuE0EURRmwAXZQ8jhCXZ/3KVaChBED8ICJySCRkBCIRcDGmLEb2sdGeXzKjhNHiCjd0k1K0ak+3dWvqiufH3/9/uQRx/Nv8y8vPizers8vLxbP0iIv13naHKlvDtJJI5UUspGVLGRenKXF6v356vXF6s2rd5cXu15bm3vxabn+tFwvPp6l3y6Y/jhH/cigiyh7va6ybe6yjpS2z+B2P4Y3wV+HV05lSnVKbUoyJZ2STcnn4aDXQZe1Dvu7ejIP+ZAny9G73edKl0nGb/e2Pu7DOXgEvU/NJe8txzDFemxYbGhsSGy02KixUWIj...
711,658
Pattern 6
Geek is very fond of patterns. Once, his teacher gave him apattern to solve. He gave Geekan integer n and asked him to build a pattern. Example: Input: 5 Output: 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1 Your Task: You don't need to input anything. Complete the function printTriangle() which takes an integer n as the input par...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1662577122, "func_sign": [ "void printTriangle(int n)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass Main {\n // Driver code\n public static void main(String[] args) throws Exception {\n BufferedReader br = new Buffered...
{ "class_name": "Solution", "created_at_timestamp": 1663240919, "func_sign": [ "printTriangle(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 ob.printTriang...
eJzs3c+OJGd23mEvfAG+hESvZ5EnIiMjUldiwAS0kLjQhpoFBxAwkKBL8U167/NGixpy2N2s6so/EZkPYEkz7KzqrO987K44zw/l//yf//t//d//9z/+z18//ctPf/7Lz5/+4fCpfvipPv3p8OnHf/vzj//084///I//+peff/mlww8//ccPP3369z8d/u4Djl/9iOEwHk6H6XA+zIflcDnUsT/J7//x7//Z3/+T3/73X/+3v/3nX/7T5/+b//2VNzy86w1XHWo41Hio06GmQ50PNR9qOdTlMHz5y/n2B73zI97z8je/9m0vfMOr/ugl...
700,321
Match specific pattern
Given a dictionary of words and a pattern. Every character in the pattern is uniquely mapped to a character in the dictionary. Find all such words in the dictionary that match the given pattern. Examples: Input: n = 4, dict[] = {abb,abc,xyz,xyy}, pattern = foo Output: abb xyy Explanation: xyy and abb have the same ...
geeksforgeeks
Easy
{ "class_name": null, "created_at_timestamp": 1615292571, "func_sign": [ "public static ArrayList<String> findMatchedWords(int n, ArrayList<String> dict,\n String pattern)" ], "initial_code": "import java.util.*;\n\npublic class MSP {\n public static void main(String[] args) {...
{ "class_name": null, "created_at_timestamp": 1615292571, "func_sign": [ "findSpecificPattern(n, Dict, pattern)" ], "initial_code": "# function goes here\nif __name__ == '__main__':\n t = int(input())\n for i in range(t):\n n = int(input())\n arr = input().strip().split()\n stri...
eJyllM1OhDAUhV3oe5ywnhh11IVPYmKNaUvR8adQBqTUaHwIfU137r0dxkHHKUolkPBz78e5pweet1/fd7YW2+kbnZw9JDNd1FVygmSfado504LpZIJE2ULJSqUXeV0tSziYfqKnjxOsNe5Rp5BIVYbLqxmub25xp3MUpsS8qnHfWLQOjuhZngf5AfoRwTmHEAJS0kvSFEoppm3rxqKmXqcAJwxPU49ow9P2haG5D5mmMQuYcl6h7qbkorsZ5G7oCPEPmHZkm/VCgzxnQ+3TblWE5JBeFl0MTLsqDOGOiQBaA5D/yEjaQFBWZQPWGWPQ...
706,219
Player with max score
Given an array arr of non-negative integers of size N, 2 players are playing a game. In each move, a player chooses an element from either end of the array, and the size of the array shrinks by one. Both players take alternate chances and the game continues until the size of the array becomes 0. Every time a player cho...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615980994, "func_sign": [ "static Boolean is1winner(int N, int arr[])" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])throws IOException\n {\n BufferedReader read = new Buf...
{ "class_name": "Solution", "created_at_timestamp": 1615980994, "func_sign": [ "is1winner(self, N, arr)" ], "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 arr = input().split()\n for itr...
eJylk7EKwjAQhh36IEfmIndJ6uCTCEYcNINL7JCCIIKTm5u+r7lUkFIrXhtayJDvvv966bV43otZXqtb2qzP6hDqJqolKHKBH+SlSlD+VPtd9PvtsYmfI+pSQhfSLlRAQkKDlhAmBQOSWSw3AxrBIFhRR4m0GUswiciKc2owYKGScAv+hjZxOnUpMhK6gAx1X2mJXgFZijxRIxpptk7Uvkcsn3Arn2hvL+Xw3cevZpaPiUq9rP+XGTopso3+hRB/d7x5zF+Gck+7
703,417
Equalize the Towers
You are given an array heights[] representing the heights of towers and another array cost[] where each element corresponds to the cost of modifying the respective tower. The goal is to make all towers the same height by either adding or removing blocks from each tower. The cost to add or remove a block for a tower is ...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public long minCostToEqualizeTowers(int[] heights, int[] cost)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass Main {\n public static void main(String args[]) throws IOException {\n BufferedReade...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "minCostToEqualizeTowers(self, heights, cost)" ], "initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n t = int(input())\n for tc in range(t):\n arr1 = [int(x) for x in input().strip().spli...
eJytlM9KAzEQxj0IvsawZ5Ekk8kfn0RwxYP24KX20IIggg+hr+jNd/CbZCsVNmu77ZQuYdL95stvJn0///y+OCtx84XF7Wv3tFxt1t01dbZfWmMMiT50ZShiTQ6Pfsl1RzfIa1aT3SV1i5fV4mG9eLx/3qwHJXb6tu6/XdLfCkVC6vtVLOkPpa6xoxtasinujTS02QvFlMk6Ji+BQkzDkXKtQxHfMGE8WcPj2hlBCUERQQFBgqgnCoN2qrXa3vGaGy9gB+SF/haOKfn6aYpahrdRSceeBBQoW2Mh4SyT9baYhmdYhmMYbkoHERftuN9f...
704,888
Maximum Handshakes
There areNpeople in a room. If two persons shake hands exactly once,find the maximum number of handshakes possible. Examples: Input: N = 2 Output: 1 Explanation: There are two people and they can shake hands maximum one time. Input: N = 3 Output: 3 Explanation: Let the people be person 1, 2 and 3. So the possib...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static long handShakes(long N)" ], "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": [ "handShakes(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.handSh...
eJylVMtOwzAQ5ID4jsjnCnm9Xj/4EiSCOEAOHAg9pFIlBOIj4H+JU7exSxc7xZdE8WR2dnbsz8vv4epiWrcv48vdm3ju15tB3DQC2t7vV9uLVSO67bp7HLqnh9fNEEE6AhzJ3Rr/+hjR76smpwK5X0UuTzP0N5dq+2S/ghZUJLaU0tZVw9kEl/mxoJ9DXcwKH1lWpyc4qVCTsY4fijVKjvsIiMY4Yxgi76whjQr4Dpy1KEk5LQHIoeE0Kc57Bo8MHhm8ZvBcayC5jojL1FFGs4hNZsmDW+XEWVowUy7R50d6rvd3iAoZchKUMp7gpM25...
704,140
Minimum sum partition
Given an arrayarr of size ncontaining non-negative integers, the task is to divide it into two sets S1 and S2 such that the absolute difference between their sums is minimum and find the minimum difference Examples: Input: N = 4, arr[] = {1, 6, 11, 5} Output: 1 Explanation: Subset1 = {1, 5, 6}, sum of Subset1 = 12 S...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1731455319, "func_sign": [ "public int minDifference(int arr[])" ], "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 Mai...
{ "class_name": "Solution", "created_at_timestamp": 1731455319, "func_sign": [ "minDifference(self, arr)" ], "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 ob = Solutio...
eJydU0sKwjAUdNGDPLIukr4ktvUkghUX2oWb2kULgigeQjfuvKn54BcmUkMIgWTmTeZNTsnlloz8mF3tZr4Xm6btOzElkVVNRkyKNBmRkqh3bb3q6vVy23evK8eqEYeUvnCS3iYCS4QeXE1KYrcouwAwKmakAzoKCPVXALx0g5Bid1hEVMOS4RAh2fbETCgvSgBn7K1zyvpEeqhRXpJ3WFIwLY88ALKERIVXMAyWMlDF0DSZPzv7mSrEwHmcgT3FD46IVxz9fvBHsEIQVjgZMBMq1k4d1aixSJk9AgF7+gQvzuM7uGZfFA==
701,213
Rotate Array
Given an unsorted array arr[].Rotate the array to the left (counter-clockwise direction) by d steps, where d is a positive integer.Do the mentioned change in thearray in place. Examples: Input: arr[] = [1, 2, 3, 4, 5], d = 2 Output: [3, 4, 5, 1, 2] Explanation: when rotated by 2 elements, it becomes 3 4 5 1 2. Input:...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static void rotateArr(int arr[], int d)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader in = new BufferedReade...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "rotateArr(self, arr, d)" ], "initial_code": "# Initial Template for Python 3\n\nimport math\n\n\ndef main():\n T = int(input())\n\n while (T > 0):\n A = [int(x) for x in input().strip().split()]\n nd = [int...
eJytU8sKwjAQ9KD/MeQskjRGjV8iGPGgPXipHioIPhD8Bf1fN0HB18YYTKGE0pndmd05Ni+nViOc0Y4u461YVKt1LYYQylUK/iX9EW2IcrMqZ3U5ny7X9f0nKLjq4Cqxb+MZXEAHhhhco+DgShLUExAPujDooY8BLH3levEIjs7gkYxhkFSGxZvveBPDq4QGVKQDLy8Y+vrwo2Hd8HV+8tbEyWwYNxH1oaiuhqKLRUHztbxUyzFqaEluhZ64zZGSCqbLy9f2bnqu617We3fO3exnM0KoVO+fvfvDKD7EMDeAJNrceExehExKBr+GENkp...
705,738
Divisibility tree
Given a tree with n nodes where n is even. The tree is numbered from 1 to n, has n - 1 edges and is rooted at node 1. Your task is to eliminate the maximum number of edges resulting in a set of disjoint trees where the number of nodes in each tree is divisible by 2. Examples: Input: n = 10 edges = {{2,1},{3,1},{4,3},{5...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int minimumEdgeRemove(int n, int[][] edges)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass IntMatrix {\n public static int[][] input(BufferedReader br, int n, int m) throws IOException {\n ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "minimumEdgeRemove(self, n : int, edges : 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...
eJztlz1uFEEQhQmIOUNpYwt1dVf/cRIkBhGAA5LBgS1ZQiAOAXcj4yrUe2UjLHssj4U3wkF/lq15W/W6Xu3ut+c/fr14xp/XP/2XN58PH9ezi/PDKznosua0rCoZR1nWIoaj+t+l4ejL2mXgmMvaRBNPf05VNAf8uSFqPP3JKtp4+rMmOnj605oEL3Y4kcPp5dnp+/PTD+8+XZxfleIiX/2fX07kZn1lo74qfJEb9U3WN++oL7O+zPo0CtSoUDtLBFDjZI0AvPEXzgFoFMkWgD9Vcgu4Su6SR8BV8pSy3enc6LTe6FSFBV/fREGnRWjm...
702,686
Buildings receiving sunlight
Given the array arr[] of heights of certain buildings that lie adjacent to each other, Sunlight starts falling from the left side of the buildings. If there is a building of a certain height, all the buildings to the right side of it having lesser heights cannot see the sun. The task is to find the total number of buil...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1617646903, "func_sign": [ "public static int longest(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 pu...
{ "class_name": "Solution", "created_at_timestamp": 1617646903, "func_sign": [ "longest(self, arr)" ], "initial_code": "# Initial Template for Python 3\n# Position this line where user code will be pasted.\n\nif __name__ == \"__main__\":\n t = int(input())\n while t > 0:\n # k = int(input())\...
eJztls1qFFEQRl34BD5BMesgXT/3p135GIIRF5qFm5jFBARRfAh9X+seAoHgDdNhQga1G4rZnOlb56u+t388//X6xTOuN2v+ePt19+ny6nq/eyU7Pb/UZVyyjovaqY1aqYUaVKcaVamwHbbDdtgO22E7bIftsB22wzbYBttgG2yDbbANtsE22AZbYStsha2wFbbCVtgKW2ErbIEtsAW2wBbYAltgC2yBLcvuTHYXX64uPuwvPr7/fL2/dfn9/HL37UzuCBYTl5AiVZrk00QXURU1URcN0SJaRZtoF13FFrFkTMzFQqyIVbEm1sVW8UVc...
705,285
Bike Racing
Geek is organising a bike race with N bikers. The initial speed of the ith biker is denoted by Hi Km/hr and the acceleration of ith biker as Ai Km/Hr2. A biker whose speed is 'L' or more, is considered be a fast biker. The total speed on the track for every hour is calculated by adding the speed of each fast biker in t...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static long buzzTime(int N, long M, long L, long H[], long 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 IOExcep...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "buzzTime(self, N, M, L, H, A)" ], "initial_code": "# Initial template for Python\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N, M, L = [int(x) for x in input().split()]\n H = [0 ...
eJzNVUFOwzAQ5MCJT7DygVOF1nEcx7wEiSAOkAOX0EMqVUIgHgH/Zdd22lSwCo3cCPdg125mZmcn9cf519XFWRi3l7S4e1XP3XrTqxtQuuksaESEArHpaAWWZ4vgbNMZ+q75gE6h4oMCwaNagWq36/axb58eXjb9Huy96dTbCg4ZSsIkAgauEUqaPIJhNJ3oArqAagTUiiWTPAYwrL/pHLNEdJpsJKkiZSxN4KgFDkMIgwWaZ7YGLPtBxAKY9wKaC06zDMIpk6NscY2slixPTvsge+8Nl2Es1yE5LxUQDA5M0fXkkomtYLNqG8yqYnWO...
704,541
Maximum height of the staircase
Given N number of square blocks. The height of each square block is 1. The task is to create a staircase of max height using these blocks.Note: The first stair would require only one block, the second stair would require two blocks and so on. Examples: Input: N = 10 Output: 4 Explanation: The max height of the stairs...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int maxStairHeight(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...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "maxStairHeight(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\n ob = Solution()\n ...
eJydkzFuAjEQRSk4yMo1inY8Y4+dk0SCKEXYgmahWCQkRJRDJIeh42g4wRuS4g8o48aFn8fz//f79PM0nXzX07Fs5nu36jfbwT02jhY9tZdys8Z1u033OnTLl/V2qCdEtBx6W/TuMGv+krkWIEnKAih5lhA1oaY5JkAmjUHYE2rKnjNAPYlK4igK4BgCBwAHW6YvHQDJhWJMqgrqWUdFZBFRve0NEtjyJleJIdoGweYY3gilaFlzvQAbhDqPgbpj9KBkqmZoxqh7a6fDknuMB2K9SEYBqVP/uuUfP4puPR1NPcYToZzJo5dfMvYj+T2Z...
712,194
Maximum point you can obtain from cards
You are given an integer array cardPoints[], where each element represents the points associated with a card. The cards are arranged in a row. In one step, you can take one card either from the beginning or the end of the row. You must take exactly k cards. Your goal is to maximize the total score from the cards you ta...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1666333786, "func_sign": [ "public int maxScore(int[] cardPoints, int k)" ], "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 Scanne...
{ "class_name": "Solution", "created_at_timestamp": 1666340513, "func_sign": [ "maxScore(self, cardPoints, k)" ], "initial_code": "if __name__ == \"__main__\":\n import sys\n input = sys.stdin.read\n data = input().strip().split('\\n')\n\n t = int(data[0])\n index = 1\n for _ in range(t)...
eJytVctOw0AM5MCBz7ByrtB6vY8sX4JEEAfogUvooZWQEIhvQHDgb5l1I1SBnCZtt7UbKa5nZ2Yf7+df3xdnOq4/8HDz0jz2q826uaKGu55dHTT5p+tzs6Bm+bxa3q+XD3dPm/XQLA/v37q+eV3QH5jfLuZD1wejs6+vvdW5zsz6dn00ekZ7pp6EAkVKlKmlop0wSU8sxIE4oshqy97sC6ogQoIIiIhICMhGLaIMEttTDra8pQ6qqdWcNSfNUXPQLJq9Ztbs6swMQP1ftHX3lQ3IgAuogAmIgEelAcUQKGBUMEoYNYwiRhWjjIvKMYLO...
703,783
Armstrong Numbers
You are given a 3-digit number n, Find whether it is an Armstrong number or not. Examples: Input: n = 153 Output: true Explanation: 153 is anArmstrong number since 1 **3 + 5 **3 + 3 **3 = 153. Hence answer is "true". Input: n = 372 Output: false Explanation: 372 is not an Armstrong number since 3 **3 + 7 **3 + ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1730109846, "func_sign": [ "static boolean armstrongNumber(int 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 BufferedR...
{ "class_name": "Solution", "created_at_timestamp": 1730109846, "func_sign": [ "armstrongNumber(self, n)" ], "initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n n = input()\n n = int(n)\n ob = Solution()\n ...
eJxrYJmazMIABhExQEZ0tVJmXkFpiZKVgpJhTJ6hgYGSjoJSakVBanJJakp8fmkJVLIytTgmry4mT6lWRwFVj6WlJcl6jM1Jt8fY3JBkPSYG5iTrMSUjDEwMSA8DSxPS3WZoQHoYGJoZkxMGpIaCAZlBB0xyUAsNgbSBpQk5gQI2gIyggegmU7OZMZkxAg5dckIKbiswz5Ef0iDagMywhgU1EWkqdooeALBKZ6k=
700,402
Max distance between same elements
Given an array arr[] with repeated elements, the task is to find the maximum distance between two occurrences of an element. Examples: Input: arr = [1, 1, 2, 2, 2, 1] Output: 5 Explanation: distance for 1 is: 5-0 = 5, distance for 2 is : 4-2 = 2, So max distance is 5. Input: arr = [3, 2, 1, 2, 1, 4, 5, 8, 6, 7, 4, 2]...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1617624240, "func_sign": [ "public int maxDistance(int[] arr)" ], "initial_code": "import java.util.*;\nimport java.util.Scanner;\n\n//Position this line where user code will be pasted.\npublic class Main {\n public static void main(String[] args) {\n...
{ "class_name": "Solution", "created_at_timestamp": 1617624240, "func_sign": [ "maxDistance(self, arr)" ], "initial_code": "if __name__ == \"__main__\":\n t = int(input())\n for _ in range(t):\n arr = list(map(int, input().split()))\n ob = Solution()\n print(ob.maxDistance(arr))...
eJydVEsKwjAUdKH3eGRdpE3ST1x5DMGKC+3CTXXRgiCKh9D7+hKqltJpjQmBhDDTeZN5vU+fy9nEjZXhzfoiDuWprsSCRJSXEUUiIFGcT8WuKvbbY119L295Ka4BdRESYiTASGpNgE3Q98L3IBb7OXgqsKoVaYopoZQyMkwFKEIohFEZoxNm0cwmnSBkH6JRjNK8YmaTjktRDEgMrGZgIkF60Jq2QYgCyTFsimG0agxS7mRNTpGYgXfyfJYeP7GhKGQNyQ8MSLjyTtNIkiHQrr898i3Ldbvqd8j2tX8Xkez+EFz62jGyGTS+NY4qHczp...
705,907
Find the Maximum Flow
Given a graphwhich represents a flow networkwith N vertices numbered 1 to N and M edges.Find the maximum flow from vertex numbered 1 to vertex numbered N. Examples: Input: N = 5, M = 4 Edges[]= {{1,2,1},{3,2,2},{4,2,3},{2,5,5}} Output: 1 Explanation: 1 - 2 - 3 / \ 4 5 1 unit can flow from 1 -> 2 - >5 Inpu...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "int findMaxFlow(int N, int M, ArrayList<ArrayList<Integer>> Edges)" ], "initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*; \nclass GFG{\n public static void main(String args[]) throws IOExce...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "findMaxFlow(self, N, M, Edges)" ], "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().strip().split())\n Edges =...
eJy1VEtOwzAQZcGCY4yyYVOh2JNxYk6CBIgFZMGmdNFKlRCIQ8B9mU9DUqjdNLRZZGyN/d6bnz/Ovy4vzvS7AV7cvhbP88VqWVxD4e7mHvjnQE0xg6JdL9rHZfv08LJa9qfe2fk2g+2rCH5ztSxLNqiLNIw6dyIFoAGS2yDxvrIFAtmCIEwmcYzc03QsSkJGwaZiAjIeNbWeCdCorX9sFLdsdB9lQYIVdY/sQrlWg89opZRUBvbbShsTWgs2a5QdmewAlQlFUS+EyutMrQbRyBGJDNNimpQWgeq0qBTfFUalKCtp/EzgjcdRp0GE0aZ+...
706,283
Coin Piles
There are N piles of coins each containing Ai (1<=i<=N) coins. Find the minimum number of coins to be removed such that the absolute difference of coins in any two piles is at most K.Note:You can also remove a pile by removing all the coins of that pile. Examples: Input: N = 4, K = 0 arr[] = {2, 2, 2, 2} Output: 0 Ex...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int minSteps(int[] A, 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 Buf...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "minSteps(self, A, N, K)" ], "initial_code": "# Initial Template for Python 3\n\nt = int(input())\nfor _ in range(t):\n N, K = map(int, input().split())\n A = list(map(int, input().split()))\n\n ob = Solution()\n pr...
eJy9lTGPE0EMhSloKOkon7Y+oRnbO+vhlyARRAEpaMIVOemk0yF+BPxfnidQEOS7bA6SaLRR1h6/Z3+z++35j1cvno3P25f88e5u+ry7vtlPbzDVza4WzJudoqPC0WBYIJhRy3SFaXt7vf2433768OVm/yunbXZfN7vp/gpHG82Q2K4wtXIJl3IZekd39AW9oc/o/If1BL2iZ1UWT8pIgY9iykIQP4hdqF14pQvWZfkGWaB008IPyyV1XJM6c/gYF+swhy0wdmeGGYwbC6zCCrRDHcpiDUpVBlWoQGsolD4kUkILfWKhRQRC6WXI9RBP...
705,215
Count Primes In Range
Given two numbers L and R(L<R). Count all the prime numbers in the range [L, R]. Examples: Input: L=1,R=10 Output: 4 Explanation: There are 4 primes in this range, which are 2,3,5 and 7. Input: L=5,R=10 Output: 2 Explanation: There are 2 primes in this range, which are 5 and 7. Constraints: 1<=L<R<=2*10**5
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "int countPrimes(int L, int R)" ], "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": [ "countPrimes(self,L,R)" ], "initial_code": "# Initial Template for Python 3\n\nimport math\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n L, R = map(int, input().strip().split(\" \"))\n ...
eJydU0sKwjAQdaH3GLJxUySZtKXxJIIVF9qFm9hFC4IoHkLvaxKrtoVpm8wiH8Kbmffm5TF/LRczFxswh+2VnXRZV2wNTORaAOaaRcCKS1kcquK4P9fV//luHm8R9DDKBiC34Y8GSWKQwNh6HERgQQMyWBGARBknKdgtTbzRCEKQoIRmmnAwa0q3y+m5OKpmwwC0U3dsqplU1JDa5S39YLXjQbmzWGYkByd51y3fe6PpiImouXwyo/9ADbDpgLb9EJ1pbStUcqwDEdRC9wv0RPX++s5numO0qRQHRGon/dknLPvuuXoD0ACJYQ==