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
701,716
First Repeating Element
Given an array arr[], find the first repeating element. The element should occur more than once and the index of its first occurrence should be the smallest. Examples: Input: arr[] = [1, 5, 3, 4, 3, 5, 6] Output: 2 Explanation: 5 appears twice and its first appearance is at index 2 which is less than 3 whose first t...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1616042083, "func_sign": [ "public static int firstRepeated(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 ...
{ "class_name": "Solution", "created_at_timestamp": 1616042083, "func_sign": [ "firstRepeated(self,arr)" ], "initial_code": "# Initial Template for Python 3\n\n# contributed by RavinderSinghPB\nif __name__ == '__main__':\n t = int(input())\n\n for _ in range(t):\n arr = [int(x) for x in input...
eJy9VMFuwjAM5TDxHVbODDVp2qZ8CdI67bD1sEvhUCQktGkfMbjxrzyHstFpZhhVi+U2keLn5xcnH3fb/XgUx3yHycPGvDbLVWtmZGzV2CQOKuOgbmkmZOr1sn5u65enxar93v9eNeZtQn2QGBt+YPSXVoB0AmRKljw8o5Ic5finlClpFcQoDjgOs4ICLCevRLEx2kUs5uQjHpuWj6UExl9JDTEScjp4CvfwDJ7DC3hgqeGsMy8E6CBAZyiHyzuW6SE0i60tLenFs9R88KRtpFPr2KN1qw54QKyhGt9eKP339OVN+e9vIMAX4IzEV0Zd...
703,463
Sorting all array elements except one
Given an array arr[] of positive integers and an integer k, sort the array in ascending order such that the element at index kthstays unmoved and all other elements are sorted. Examples: Input: arr[] = [10, 4, 11, 7, 6, 20], k = 2 Output: [4, 6, 11, 7, 10, 20] Explanation: Sorting array except an index 2 So, [4, 6, ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public void sortExceptK(int[] arr, int k)" ], "initial_code": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int t = scanne...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "sort_except_k(self, arr, k)" ], "initial_code": "def main():\n t = int(input())\n for _ in range(t):\n arr = list(map(int, input().split()))\n k = int(input())\n\n solution = Solution()\n solu...
eJzFVTtOAzEQpaDhFqOtEfKMvWubkyCxiAJS0CwUQUJCIA4BB6HjeDz/QlBik4QgXHjX8sx743kz9svh28fRQRxn7/g5f+xuprv7eXdKHY8TKwzq88QU1uS9J8GXFT7E1JMep747pm72cDe7ms+uL2/v5wWENAySqWRnXgVV4/Q8Tt3TMX0PwIcRnLyLs43zQEKGBnIBmMmOk6nSBzsL+2ibnL+AEqivkLNoMj3cXYiZmYVYs2GcZ2DLQPSihElEtBiSXgYBlROvFWnWopEYV4tsH+Drc+bs0JPRggNrUFjC2mjCGgcOv6AS7NAAcogQ...
703,823
Ways to sum to N
Given a set of m distinct positive integers and a value β€˜N’. Count the total number of ways we can form β€˜N’ byaddingthe array elements. Repetitions and different arrangements are allowed.Note: Answer can be quite largeoutput the answer modulo 10**9+7. Examples: Input: m = 3 , N = 7 Arr[] = {1,5,6} Output: 6 Explanati...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int countWays(int arr[], int m, int N)" ], "initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*;\nclass GfG\n{\n public static void main(String args[])\n {\n Scanner sc = new S...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "countWays(self, arr, m, n)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n m, n = list(map(int, input().strip().split()))\n arr =...
eJytUz1Pw0AMZUCMbOxPmSvkO5/vzvwSJIoYIANL6NBKlRCIHwH/F1/EVwenKZBTokiJn/0+/HL8dnZyNF6Xp/Zy9djdD6vNurtAF5ZDQHt0C3T9dtXfrvu7m4fN+vv783LonhbYLYooy4GRnLLolDGk1UawU5icwkAIRDS+RAITEkEImVAIlaDjDx6LXFMuEovHpmHRKMWc43ThTJG0ek0qVKyHDS0BEiEmRoIIJEOKgynEQWr0bOAPVZgZzMlu8YZzEDJUtcnadG3CNmVHOUxbT0/aM06IFg2jVaoeiBBa62aERQSmDgwEppwBe96m...
701,195
Power Of Numbers
Given a number and its reverse. Find that number raised to the power of its own reverse.Note: As answers can be very large, print the result modulo 10**9 + 7. Examples: Input: N = 2, R = 2 Output: 4 Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided ...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1731334387, "func_sign": [ "public int reverseExponentiation(int n)" ], "initial_code": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int T = sc.next...
{ "class_name": "Solution", "created_at_timestamp": 1731334387, "func_sign": [ "reverse_exponentiation(self, n)" ], "initial_code": "# Input handling\nif __name__ == \"__main__\":\n T = int(input()) # test cases\n for _ in range(T):\n n = int(input()) # input N\n solution = Solution(...
eJzs3UvKrVuT3XcX7H4kX1mF57Kem5vgFhic4IKtgippFSQwCIGb5eY5fv+502BQdsDsV+Lkd85+91rPZc6YEWOMGPF//ff/8//9P/0P/93/8l/+8R/+5T/+5//0j//xn/6x//O/bP/4d//0j3//f/7Hf/+//ad//7//r//Hf/5Pf/5o++d/+cd//Xf/9P/95f3f+OX9v/nL/9ZH7//tz97+7d//t/7Cn59/++/9+flv/fXrdx7/9iVe2/E9v/u6tu17tnP/3u36fdfx/K7fux37cR37/c4nPL/5s9+5Hdv8xnGe3+973vu9rnt+eb/3...
705,148
Pairs of Adjacent elements
Given an array arr[] of positive integers. The task is to count consecutive pairs of adjacent elements. A pair is said to be consecutive if the second element in the pair is greater than the first element by 1. For example, (4,5) is a pair of consecutive elements. Examples: Input: arr = [5, 7, 6, 7, 4] Output: 1 Expl...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int adjacentPairs(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 BufferedR...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "adjacentPairs(self,arr)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n arr = input().split()\n N = len(arr)\n for i in ra...
eJxrYJn6j4UBDCK+AxnR1UqZeQWlJUpWCkqGMXmGSjoKSqkVBanJJakp8fmlJVApg5i8upg8pVodBTT1BmBAqi4FKCTPNgVLMFDAzsVhphFut5DlB6IsNSTKIyTabKRgrGCqYKJgpmCuYKlgAXSCgiGukDTG6WuQGUD9lMUAmLSAUOakB6AhEJtS5nt8nscV5UYKCJ/gDz5CwWBClXAwJCsgYAnQktzkS4mfDWGepiD2KXO+IWYQEJ+sY6foAQBsPHR2
700,203
DFS of Graph
Given a connected undirected graph represented by an adjacency listadj, which is a vector of vectors where eachadj[i]represents the list of vertices connected to vertexi. Perform a Depth First Traversal (DFS) starting from vertex 0, visiting vertices from left to right as per the adjacency list, and return a list conta...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public ArrayList<Integer> dfsOfGraph(ArrayList<ArrayList<Integer>> adj)" ], "initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass GFG {\n public static void main...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "dfsOfGraph(self, adj)" ], "initial_code": "if __name__ == '__main__':\n T = int(input())\n while T > 0:\n V, E = map(int, input().split())\n # Create adjacency list with V vertices\n # List of lists ...
eJztl0Fu1EAQRVlwAW5QmnWE3FXddpuTIGHEArJgY7JIJCQE4hBwInaciv9/TRIU5GRGYgHRzMKdeHqqq96vX5a/Pv3+89kTfV7+wB+vPu3erxdXl7sXtivLWgYrbVlx5cVxw4KXuqxujZdxWcMmXvqyVpuXtfHeyHsT73Xem23gt213Zrvzjxfnby/P3735cHW5PwnxDVFsNEQ1RLFuy/plWXefz+xORm6lH51RGZhSKcxpZk68MesGSmSAkhl27X4gzRkpMgRyxXGIspVsnnNArpWnN/41Pnh6Hlo3AdmwGWDjJ54J3nfw1mEDPvnr...
703,468
Multiply left and right array sum
You are given an array of integers, your task is to divide the array into two sub-arrays (left and right) containing half of the array elements. Find the sum of the subarrays and then return the multiply of both the subarrays. Examples: Input: arr = [1, 2, 3, 4] Output: 21 Explanation: Sum up an array from index 0 t...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1619177699, "func_sign": [ "public int multiply(int[] arr)" ], "initial_code": "import java.util.*;\n\npublic class GFG {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int t = sc.nextInt();\n ...
{ "class_name": "Solution", "created_at_timestamp": 1619177699, "func_sign": [ "multiply(self, arr)" ], "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 = Solution()\n ...
eJy1VMtKA0EQ9CD4G8Weg0zPzqPbLxGMeNAcvMQcEgiI4kfo53jzw6xdQjTqTHYT3KFCYGu7p7ur+uX07ePspH8u3/nn6rG5ny9Wy+YCjUzn4hw80RKBiEQiMqGEEeS46byZoJmtF7Pb5ezu5mG13MQg2fXvn0l5muB3+CNQzhoqSc0g2P0pBqrFEXi0CIhIyFAwDm8lEA9pIQESIQmSIQox9rGYRqOPxSyDTqUZ4qxUQsSgUwztY3W0bK2xLxmWYBEWYC3Mw9h16segCmXrEjRCA7SFemh5HCqp0qlOqlQqhUqdUqZUKUXaper10k2H...
711,400
Number of Ways to Arrive at Destination
You are in a city that consists ofnintersections numbered from0ton - 1withbi-directionalroads between some intersections. The inputs are generated such that you can reach any intersection from any other intersection and that there is at most one road between any two intersections. Examples: Input: n=7, m=10 edges= [[0,...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1658245029, "func_sign": [ "static int countPaths(int n, List<List<Integer>> roads)" ], "initial_code": "// Initial Template for Java\n\nimport java.util.*;\n// Position this line where user code will be pasted.\n\nclass GFG {\n\n public static void m...
{ "class_name": "Solution", "created_at_timestamp": 1658246530, "func_sign": [ "countPaths(self, n: int, roads: List[List[int]]) -> int" ], "initial_code": "# Initial Template for Python 3\n\nclass IntArray:\n def __init__(self) -> None:\n pass\n\n def Input(self, n):\n arr = [int(i) f...
eJytlj1uFEEYRAmIOUNrYwv19s/0DBIZh0ACRAAOSIwDW0JCIA4B96W+V21AttZ4bTuoh2T8ZmZ3q7Z/PP316tkTfl6/1D/efN19Oju/vNi9SLv927OSFDntA7uTtDv9cn764eL04/vPlxd//9d3/fLbSTr0p/nq52hHTfXP5fdpGksqB0XlgKjdFJVU7/FUPbUDopraPXz/PmG2b2qPFLW0XBdl39j+Slvv/9glS71ttz96Sz3xEi2BJY3ASGtgTVtAkfl7pUVK357St6tEF4kwEmUk0ki0kYiVBbOyYFYW36Q+MH70mgpmZcGsLJiV...
704,563
Narcissistic number
Given N, check whether it is a Narcissistic number or not. Examples: Input: N = 407 Output: 1 Explanation: 4 **3 +0 **3 +7 **3 = 64+0+343 = 407 equals to N. Input: N = 111 Output: 0 Explanation: 1 **3 +1 **3 +1 **3 = 1+1+1 = 3 not equals to N. Constraints: 1 <= N <= 10**5
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int isNarcissistic(int N)" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])throws IOException\n {\n Buffered...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "isNarcissistic(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.is...
eJytU8sKwjAQ9KD/UXIW2baJbfwSwYgH7cHL6qEFoSjiN+j/uo32QV9JxD0sbZeZnU4m9+nrMZvoWuf0sMnZEc9ZylYeEwo5RAp9ESqUPOIK4wBi+qCQzT2WXM7JPk0Ou1OWfiE0uel5b2fXudfgJ9YwgqLR2F+G3IG2RRUoBK1RGDigD02L/YDUcLFUGMWSXoFqkAoaVDBMG5SuCeqx1c+1GHzNPIrrImRRBu39KGeQjU1dUz7bTIYM7YSe2Lh51AzLfzQUCkwejkipnbQRNZIUouNV5NCYueH7aHchYVSPlHUYf02k1PSgqBzUOR1b...
702,887
Check Arithmetic Progression
Given an array arr[] of integers. Write a program to check whether an arithmetic progression can be formed using all the given elements. Examples: Input: arr[] = [0, 12, 4, 8] Output: true Explanation: Rearrange given array as [0, 4, 8, 12] which forms an arithmetic progression. Input: arr[] = [12, 40, 11, 20] Outpu...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public boolean checkIsAP(int[] arr)" ], "initial_code": "// Initial Template for Java\n\n// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\n// Driv...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "checkIsAP(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 ans = ob.checkIsAP(arr)\n ...
eJylk0EKwjAQRV3oPT5Zi3TSpFb37jyAYEVEKwhSi7YgiOIh9L6GjC4UKjqZWbxCmQ//Z+bavo87LV+TkfuYntSmKOtKDaEoK0h1ofJjmS+rfDXf1dXzV7Wv86y4ZIU6d/ExEvlCAwWCiKH/H+vjo+VWBr4YKUOg5ucSHrcMw4gZmkEMQVIaBglSFzVIgwwoAaXQAinrRSy0RWxhmhTWi+2h+d0I2nfs2ggUItjA3bGhzmXWnxpRkAjvi+ReyD19WPJvh/Pten5KQeY/4GAbKNxiekXp7PySw+zWewAm1pH8
702,776
Number and the Digit Sum
Given a positive value N, we need to find the count of numbers smaller than or equal to N such that the difference between the number and sum of its digits is greater than or equal to the given specific value K. Examples: Input: N = 13, K = 2 Output: 4 Explanation: 10, 11, 12 and 13 satisfy the given condition shown...
geeksforgeeks
Easy
{ "class_name": "Sol", "created_at_timestamp": 1615292571, "func_sign": [ "public static long numberCount(long N, long K)" ], "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 ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "numberCount(self,n,k)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n for _ in range(int(input())):\n n, k = (int(x) for x in input().split())\n ob = Solution()\n ...
eJy1Vr2OFDEMpqDiKaypTyj/se9JkBhEAVvQhCv2JCQEOomOGt4X20m0c9xkdm/31oUznk382bE/7zy8/vv7zSuVd7/44f336Uu5u99PtzD5uVhjwJq5OFkj29GAM9MNTLtvd7tP+93nj1/v920/2rn85D19dXWdftzAwqtTr02AVGSzDzFlJCDMKYYBBO/Vcx3BhUSGzBoOR09NQAHZVtfeWahwc+kvDNR1DIsCrTjsJXqDwanFBrKkUa7NvQD2AEASHSDFYKn5IrQU45HUCNoFYhdQPZfcBVSPM6s3WpNBzPwikVp8KrGVcS2GuLxO...
705,091
Game with String
Given a string str of lowercase alphabets and a number k, the task is to print the minimum value of the string after removal of k characters. The value of a string is defined as the sum of squares of the count of each distinct character present in the string. Return the minimum possible required value. Examples: Input:...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int minValue(String s, 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 Buffered...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "minValue(self, s, k)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n s = input()\n k = int(input())\n\n ob = Solution()\n ...
eJytU8tOhEAQ9KD/Qea8MYBZjX6Bt72a2MYIDG+aAWZ4aDR+hP6vQMxuyGYaxJ3TJDPV1VVd/Xn+vbs4G8/DfX95fGMRCiXZncEswBdAE5BtDMZbwV3JvedcycP7R//4vjGOQJYWZOpAJEpLNcCu/k7muB6npG1p4HaFPMdxXUBbi7zWIF/3h+K1tR2PxJ7Hue8HQRhGURwnSZpmGWKeC1EUZVlVUipV103Ttl03ENkE0y3ljR+EUZykGeaiKCup6qbt+noWkSKd8IPXi/ybmfVRGQtgkoS1WVo0HkokAJ1FLXTQgqQnN7P5X7kA5q+b...
712,431
Non-overlapping Intervals
Given an 2D arrayintervals of representing intervals where intervals [ i ] = [starti, endi), return the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. Examples: Input: intervals [] = [[1, 2], [2, 3], [3, 4], [1, 3]] Output: 1 Explanation: [1, 3] can be removed and the...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1666678237, "func_sign": [ "static int minRemoval(int intervals[][])" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.math.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[...
{ "class_name": "Solution", "created_at_timestamp": 1666815057, "func_sign": [ "minRemoval(self, intervals)" ], "initial_code": "# Initial Template for Python 3\n# Position this line where user code will be pasted.\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(...
eJzVVLtOwzAU7cAAf3GVuUK+fsXmS5AwYoAOLIahlZAQiI+Aj2XjnpuoooNbpYUiuiRx4/PyuXk7+ZidzfR3+Xk6m109d/f1cbXsLqjjUkOpTL5US3LnKJbqqZdlSqV2c+oWT4+L2+Xi7uZhtRx3uVJf5c+XOW1CRWxjIzfEttREDHBPVpY4kpU1TmRDE9g3gBM0sjFQmTNk5gSdWYXmCMYssD1lD97smhR9gwKymRwYPAgC8NVQD/Sk4OpJXszEukVtNohCg0jgDCEJUFhQOFB4UARQRKWYmFAYEtKAgJjWxxgnY8WxEW7wr9ZH19At...
706,080
Gadgets of Doraland
In Doraland, people have unique Identity Numbers called D-id. Doraemon owns the most popular gadget shop in Doraland. Since his gadgets are in high demand and he has only K gadgets left he has decided to sell his gadgets to his most frequent customers only. N customers visit his shop and D-id of each customer is given ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "ArrayList<Integer> TopK(ArrayList<Integer> array, int k)" ], "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 Scann...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "TopK(self, array, k)" ], "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 array = [int(x) for x in input().strip()....
eJztl8tu1DAUhlnwBDyBlXWF7ON7n4NFpQ5iAbNgE7qYSkiIqg9R3reO/Tf5S3EoMxWiZXK+zxqpvsR1juNcv/5x/uZVvc7elR/n34bP48XlbjhVg9mMM8OJGrZfL7Yfd9tPH75c7u6qqM14Vf76/UT91FAX1YM4oC8pYWu4FpvRdvtypZp0+/Ob0asWrS+LmMaodyndnn2p1ulXpvvUKtdIiFgilPCKhyx37leGSKWDqVlnoDCNUy7VylyuuUi1WJsBNer0b+vazdVWF63W6vRT/h+16LTtLrdu81NLgcmpNr/JCAP00EELBRqomynD...
705,636
Adventure in a Maze
You have gota maze, which is a n*nGrid. Every cell of the maze contains these numbers 1, 2 or 3. If it contains1 : means we can go Right from that cell only. If it contains2 : means we can go Down from that cell only. If it contains3 : means we can go Right and Down to both paths from that cell.We cant go out of the ma...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int[] FindWays(int[][] matrix)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG\n{\n public static void main(String[] args) throws IOException...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "FindWays(self, matrix)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n = int(input())\n matrix = []\n for _ in range(n):...
eJzVVUsKwjAQdeHCYwxZi3QSq+BJBBUX2oWb6qKCIIKH0Puaz8QfM8VUUWzSfKa8eZP5pMf2Oe+0/DPu2cVkr1blZlupESiclrYb1QVV7DbFoiqW8/W2il/BwLRUhy48QrRFgR0MoIjsS0gNYRCQGWQs0jg62x4nQckAMGe19J3lvtUsEi3L/XFCS1k2cQBpMNFayQEaULNaMLse8779tTA9Xoag5FP3RofepG7jM502Yq5pZHkGUSPFy0fPCojLBC7HFqQ68AU5WYfRDjFdhqD5UnvjpOaVGkPgS8ydtOZC4W8UD6pDMTAgnO3fz+rf...
703,137
String Reversal
Given a string, say S, print it in reverse manner eliminating the repeated characters and spaces. Examples: Input: S = "GEEKS FOR GEEKS" Output: "SKEGROF" Input: S = "I AM AWESOME" Output: "EMOSWAI"
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public String reverseString(String s)" ], "initial_code": "import java.io.*;\nimport java.util.*;\nclass GfG\n{\n public static void main(String args[])throws IOException\n {\n BufferedReader br = new BufferedReade...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "reverseString(self, s)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n s = input().strip()\n ob = Solution()\n ans = ob.re...
eJy1Vk1v00AQ5cCNPzGKxK1Canvjtl6v7XH2y/vhL4I4QA9cTA9FQkIgfgT8X2adAFGJ27RKLcuxd2PPm3nvze6P57/OXjybj/4l3bz5uvo4XX++Wb2G1eVmqoSUBjrjZL6ZQiWgicjXkDnTaShMD3VU1oNphYM0Ldk4QG7KzcQynouirLBeS6WNbZwPse36YVydwerqy/XV+5urD+8+fb7ZRcslfVRUm+n7ZipNPoxMiiq41lsV677QXbbm2MzT49B3bQzeNdZoJdc1VmUhcp6xeXr17Qz20rggMKCYBgZWzj+caSbB0lXRGz5aQs+Z...
702,662
Find Unique pair in an array with pairs of numbers
Given an array arr where every element appears twice except a pair (two elements). Return the elements of this unique pair in sorted order. Examples: Input: arr[] = [2, 2, 5, 5, 6, 7] Output: [6, 7] Explanation: We can see we have [2, 2, 5, 5, 6, 7]. Here 2 and 5 are coming two times. So, the answer will be 6 7. Inp...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1617216538, "func_sign": [ "public ArrayList<Integer> findUniquePair(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[]) t...
{ "class_name": "Solution", "created_at_timestamp": 1617216538, "func_sign": [ "findUniquePair(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 ...
eJylVM1OwzAM5oDEa1g9TyhO4jTlSZAY4gA9cBk7bNIkBOIh4Dm5cSZ2zGCo3trNiT9FtWsn/ns7//i6OBO6/iyHm+fmcbFcr5oraHC+QEDwZYWyItB80cyg6TfL/n7VP9w9rVeqKrLXIn6ZwT8LDngTb+/AE+/gZBPv6HijY4KOyfQiUlH1znDHGhkqoly8XK2sVFYLuawOOtBLoekpiNB4kNy2PKZyUI7KVDg5Z5reyoet+xBLrARTmzsniBVNm1XLskkS2orxD6YtomIrXzKj6avqIHZkJgGZoKJngsCk58gExFTPdhbkL9G0k+Hc...
701,733
Common Elements
Given two lists V1 and V2 of sizes n and m respectively. Return the list of elements common to both the lists and return the list in sorted order. Duplicates may be there in the output list. Examples: Input: n = 5 v1[] = {3, 4, 2, 2, 4} m = 4 v2[] = {3, 2, 2, 7} Output: 2 2 3 Explanation: The common elements in sorted...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1731518154, "func_sign": [ "public static ArrayList<Integer> commonElement(int a[], int b[])" ], "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 GF...
{ "class_name": "Solution", "created_at_timestamp": 1731518154, "func_sign": [ "common_element(self,a,b)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n # n=int(input())\n a = list(map(int, input().split()))\n...
eJylVEtOwzAQZQH3eMq6Qv7FSTgJEkUsIAs2oYtUqoSQOASckB2n4HmcVAXsUofYicafeTNvPnk9f/+8OJPn+oPCzXP1OGy2Y3WFSq+Hw1mtUPW7TX8/9g93T9txvgUevazwXdFSBQZWJIcaPgtgkwA1J6YhIJOUAalzIOIFXFClC54gjmuDPKE0lFYRK6BZQZQRD+bN2WN/hG4KnBDTp0BJPFLo0KKREanxpF0PYe3FF6Gbz55Ks6WGrqEdNBEZLY29KYlhNL9fxpBCQeUtmbSlkF2q0hKBOsIEQCtyw9dGS4krRcEy6qAUqN+QShc4...
712,234
Prefix to Infix Conversion
You are given a string Sof size N that represents the prefix form of a valid mathematical expression. The string S contains only lowercase and uppercase alphabets as operands and the operators are +, -, *, /, %, and ^.Convert it to its infix form. Examples: Input: *-A/BC-/AKL Output: ((A-(B/C))*((A/K)-L)) Explanation:...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1666246418, "func_sign": [ "static String preToInfix(String pre_exp)" ], "initial_code": "// Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.math.*;\nimport java.io.*;\n\nclass GFG {\n public static void main(String[...
{ "class_name": "Solution", "created_at_timestamp": 1666250303, "func_sign": [ "preToInfix(self, pre_exp)" ], "initial_code": "# Initial Template for Python 3\n\n# Position this line where user code will be pasted.\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n prefix =...
eJytk81OwzAQhHMofY7IUiT/1Fi9crPX7jMgEcwBcuASekglpArEQ8DzwiYpQj2MI1X47Jn5drz+WH2tr6rp3H6vquruKJ77/WEQN7XYtn32OWSKYlOL7nXfPQ7d08PLYThdkD7LkCXlqJRq+/e2F2+b+tzB+QDVLiBVw7kEdQ2nEkzUxgeLmaU3QWlJNmKHArOGzDwpRsajZk5zMWFcTswyugRxreE7xYFl0NwXT4zQm/GhqUAxPzWbNFExCirOjjYumrTDNHY20jyTTGaHV2dsJi1WA2FCuZeAZHSZjvy8OadYqKdF/d+/m5wwCrJi...
712,384
Assign Cookies
Assume you are an awesome parent of some children and want to give your children some cookies. But, you should give each child at most one cookie.Each child i has a greed factor greed[i], which is the minimum size of cookie that the child will be content with and each cookie j has a size cookie[j]. If cookie[j] >= gree...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1666675622, "func_sign": [ "public int maxChildren(int[] greed, int[] cookie)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.math.*;\nimport java.util.*;\n\npublic class Main {\n public static ...
{ "class_name": "Solution", "created_at_timestamp": 1666504140, "func_sign": [ "maxChildren(self, greed, cookie)" ], "initial_code": "# Initial Template for Python 3\n# Position this line where user code will be pasted.\n\ndef main():\n t = int(input().strip())\n for _ in range(t):\n greed = ...
eJxrYJnay8oABhFtQEZ0tVJmXkFpiZKVgpJhTB4QGSnpKCilVhSkJpekpsTnl5YgZOti8pRqdRRQtRgBdeHQYoBDi6EBDCCzSbQXoVEB2TxLGFAg32QFKMTtM5xakXSTqNVUAQqRmDiMMMXpcCMFYwUTiBEmQKYRTlfgMgJkAAiaQEwDm4fDCGPcwQeOEnAEQGKBsJfwxIUBZuCAJcAMQ1IjF8ODhqT7EDOQyAgleEoBeon01IIeLpQHDHr6I8M/hmg5AM4kNzcYGhKVH0zwZWTCTiM3r0NyB458R0wmhIVl7BQ9AMPTlDI=
703,705
Sum-string
Given a string of digits, the task is to check if it is a β€˜sum-string’. A string S is called a sum-string when it is broken down into more than one substring and the rightmost substring can be written as a sum of two substrings before it and the same is recursively true for substrings before it. Please note that, the r...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int isSumString(String S)" ], "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 BufferedRe...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "isSumString(ob,S)" ], "initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n S = str(input())\n ob = Solution()\n print(ob.isSumString(...
eJxrYJlazMIABhE5QEZ0tVJmXkFpiZKVgpJhTJ6hko6CUmpFQWpySWpKfH5pCVTKICavLiZPqVZHAU29EakacOowxGmFsamFobERLqfh1GcAhKS6zsDAyMDA2MCARLsMDMl1pSUEkOhOXO7DHU3GJIc6WdYgfERmDMBDEu4GnEGK1xUGQGyEO7Hh0mtJZnwYGiI0QwIBh1+ggUOi+aR6wwh3hBMONXLDjFCgxU7RAwBrWl5/
703,720
Count divisors of product of array elements
Given an array arr, the task is to find the count of factors of a number x which is a product of all array elements Examples: Input: arr[] = [2, 4, 6] Output: 10 Explanation: 2 * 4 * 6 = 48, the factors of 48 are 1, 2, 3, 4, 6, 8, 12, 16, 24, 48 whose count is 10. Input: arr[] = [3, 5, 7] Output: 8 Explanation: 3...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1617639273, "func_sign": [ "public long countDivisorsMult(int[] arr)" ], "initial_code": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int t = Integer...
{ "class_name": "Solution", "created_at_timestamp": 1617639273, "func_sign": [ "countDivisorsMult(self, arr)" ], "initial_code": "# Initial Template for Python 3\ndef main():\n T = int(input())\n\n while T > 0:\n a = list(map(\n int,\n input().strip().split())) # Conver...
eJydlDFOBDEMRSn2IF+pVyh2EifhJEgsooApaIYtdqWVEBKHgNPQcTI8w0iAZA+CqVLk237/x/O8eX3fnM3f5Zserh7D/bg/HsIFAu1GihElggsohi3CcNoPt4fh7ubheFhu5bgbw9MWP4WMhIIKIlBylJItJTFI2zXw3Dd5fbmwJU/o4IpGjozIUimjonqdTEJly2ACN6TiKLvY3mQ0kCAxJIO0AhdxSqRqmqR91eKEnFEKRFCVuaF3D1uiSdE7usoquqB7GJSyHRUmFJlg1D+eDFGqOTqnUqnmFN4LMRMmL1rnNiariuGVFM8tIRv4...
702,890
Left most and right most index
Given a sorted array with possibly duplicate elements. The task is to find indexes of first and last occurrences of an element X in the given array. Examples: Input: N = 9 v[] = {1, 3, 5, 5, 5, 5, 67, 123, 125} X = 5 Output: 2 5 Explanation: Index of first occurrence of 5 is 2 and index of last occurrence of 5 is 5. ...
geeksforgeeks
Easy
{ "class_name": null, "created_at_timestamp": 1615292571, "func_sign": [ "public pair indexes(long v[], long x)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\nclass pair { \n long first, second; \n public pair(long first, long se...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "indexes(self, v, x)" ], "initial_code": "# Initial Template for Python 3\n\ndef main():\n T = int(input())\n\n while T > 0:\n n = int(input())\n a = [int(x) for x in input().strip().split()]\n k = in...
eJytlU1OwzAQhVkgcY1R1gXF49hxOAkSRiwgCzami1RCQiAOAbdkxwWwJzWYtOOU1MlUqvLzzbzx8+Tt9OPr7ISOq0//5/q5enDrzVBdQiWsE7X/wc7pL1pXraDqn9b93dDf3z5uhu1bNXTWvfrbLyvYB0OQ0IACDS0Y6ICu1iyum8UhIQM0YJV1yMIEyCxsPBOgdZKFeQGzQmUq1rqGhVHhe2GYyIzIUSzJJbimBG2uWhXy769WjdInfYzQfN18E+Rkef7WnCagJOSF4AYKXw/6sE7xa+kfa7ieqdRpMZP55f+kkB5CoUBoEC0IQ9Fl...
709,986
Smallest window containing 0, 1 and 2
Given a string S consisting of the characters 0, 1 and 2. Your task is to find the length of the smallest substring of string S that contains all the three characters 0, 1 and 2. If no such substring exists, then return -1. Examples: Input: S = 10212 Output: 3 Explanation: The substring 102 is the smallest substring...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1645891581, "func_sign": [ "public int smallestSubstring(String S)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nimport java.lang.*;\n\nclass GFG {\n public static void main(String args[]) throws IOExcept...
{ "class_name": "Solution", "created_at_timestamp": 1645891581, "func_sign": [ "smallestSubstring(self, S)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for i in range(t):\n S = input()\n ob = Solution()\n ans = ob.smalle...
eJxrYJlqwsoABhG6QEZ0tVJmXkFpiZKVgpJhTJ5BTJ6SjoJSakVBanJJakp8fmkJVFIXKKtUq6OAqt6QRPVGJKo3MMStwxirg4wMjEjWZGRoAESk6TGAA1KDzAAGSdUIdCXQnSQ60wgYIqT6DRweyIFJatjExEDSBjm6YPZDeEguIMs4kl0BTQsxhmhxjMZFhGwMUgIi1YFQaxAuBSEUf0OCgYigwWm3Cb4YQnY8mg9Jzg2Q7I0cYKTmdkPCLouJAbuN3DyEMB3TeFD44/V07BQ9AMNBkdo=
717,670
Two Swaps
Given a permutation of first n natural numbers as an array arr[]. Your task is to sortthearrayin exactly two swaps. If It is possible to sort the array then return true otherwise return false. Examples: Input: arr[] = [4, 3, 2, 1] Output: true Explanation: swap(arr[1], arr[4]), now arr[] = [1, 3, 2, 4] swap(arr[2],...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1697475696, "func_sign": [ "boolean checkSorted(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 s...
{ "class_name": "Solution", "created_at_timestamp": 1697475696, "func_sign": [ "checkSorted(self,arr)" ], "initial_code": "if __name__ == \"__main__\":\n t = int(input())\n while t > 0:\n arr = list(map(int, input().split()))\n ob = Solution()\n res = ob.checkSorted(arr)\n ...
eJyllE0KwjAQRl3o3p3bj6yLmL9GPYlgRUQrCBKLtiCI4iH0vqZpwVZpwTGrEPIyMy+T3LvPQa/jx6zvJvML29kkS9kUjEdWQ0BCgbMALD4n8TqNN8tDlpZbtqv9KY7sLbLsGqDOhtCOlO4ECs09qaBJbBGXwkpwR/rcCbTxdG5MIyRlrj0tKOwIE4xh8L/4nBeNBaTHrBkWPjTFvFFveZJkz3drc7O25F1RRnHmEpdKoqVdW2IbVX1o/zr4bEKeH04QQtJffz/0r+O7jnKlKId+z/rHn2XxGL4Aa2+JaQ==
714,010
Make the array beautiful
Given an array of negative and non-negative integers. You have to make the array beautiful. An array is beautiful if two adjacent integers, arr[i] and arr[i+1] are either negative or non-negative. And you can do the followingoperation any number of times until the array becomes beautiful. Examples: Input: 4 2 -2 1 Out...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1676012645, "func_sign": [ "public static ArrayList<Integer> makeBeautiful(int[] arr)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass IntArray {\n public static int[] input(BufferedReader br, int n) throws IOException {\n S...
{ "class_name": "Solution", "created_at_timestamp": 1676012645, "func_sign": [ "makeBeautiful(self, arr: List[int]) -> List[int]" ], "initial_code": "# Initial Template for Python\n\nif __name__ == \"__main__\":\n t = int(input())\n\n for _ in range(t):\n n = int(input())\n arr = list(...
eJydVEEOwiAQ9NCHbDgXAwV68CUmYjxoD16whzYxMRofoa/z5ksEWhu0WVLaA2myO7szswv37PnOFv5bv+zP5kKOpm4bsgLCtWHaaENyINW5rvZNddid2qYPa3OzsWsOv5AOhWAYAiq0UUBVai+hDeVQABUo0oUwLAdaAA7FkNJ2FbYniAgYwSrP2DbuDpw2RwqUjrZTDBIUlGgB/o1jVZwE6Q2wmTEmAlAynHkTA0ETpGHzKP3uBGOZojKyTwhERYxN6UIlkj0uzWZco8EOPbIj2Y3A0+Rl/+MxmwbteUhuKw1sNOUmNixES/hixGX5...
705,122
Find the Safe Position
There are n people standing in a circle (numbered clockwise 1 to n) waiting to be executed. The counting begins at point 1 in the circle and proceeds around the circle in a fixed direction (clockwise). In each step, a certain number of people are skipped and the next person is executed. The elimination proceeds around ...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int safePos(int n, int k)" ], "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": [ "safePos(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 ...
eJytlM1KxDAQxz2IzzHkvEhmmmm33r35AIIVD24PXuoeuiCI4kPo+zr5APcjk3axhXxQMr/85z9Jvi5/7q4uwnd/K5OHd/MybHejuQHD3cBQdQNaoG6owXVDA438tBakmRWY/m3bP4/95ul1N6YoWfUpa076ug2D+VjB3h4eD+j3sH7waFLAGOJlYRjdOsuT3cl6kcSA1gOBOOIrhVtFeXtSW8yhxQNk4MBkLfsY6eocAEOuxcDTLZPZcaIFJ285eZPz+I8xVUA8YOXLJsIIQlfOhxQ9rm1BWiq45xT0EB1UPOtUykqYKiUbl7zRJHnP...
714,128
Maximum Number of coins
We have been given N balloons, each with a number of coins associated with it. On bursting a balloon i, the number of coins gained is equal to A[i-1]*A[i]*A[i+1]. Also, balloons i-1 and i+1 now become adjacent. Find the maximum possible profit earned after bursting all the balloons. Assume an extra 1 at each boundary. ...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1677586318, "func_sign": [ "int maxCoins(int N, ArrayList<Integer> arr)" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass GFG{\n\tpublic static void main(String [] args) throws IOExce...
{ "class_name": "Solution", "created_at_timestamp": 1677586318, "func_sign": [ "maxCoins(self, N, a)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n for _ in range(int(input())):\n n = int(input())\n a = [int(i) for i in input().split()]\n pri...
eJydVEsKwjAUdNGDhKyL5GM2nkQw4kKzcBO7aEEQxUPoWdx5NpM0/tB5mLalFF7nzXszQ07V5VaN0jW7ho/5nm9807V8yri0PjyC14y7XeNWrVsvt12bq8L6o/X8ULMviBQIFCoApgITK+VSiYtRfJhRR0aDSQ0JjLzlW+p+4KEjTwKcJTgAKwqYpYJgKTRkNsme/i40SQ8IBPz/x2rvOchBEq91i6X6p+VDDU/IEZtAPYzAisQalTzSQ0U6OMA5KQ0aVEYdYNwQCnE9j474svZDeKhVbrY4j++JW3C2
705,577
Eulerian Path in an Undirected Graph
Given an adjacency matrix representation of an unweighted undirected graph namedgraph, which has N vertices. You have to find out if there is an eulerian path present in the graphor not.Note: The graph consists of a single component Examples: Input: N = 5 graph = {{0, 1, 0, 0, 1}, {1, 0, 1, 1, 0}, {0,...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int eulerPath(int N, int graph[][])" ], "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 ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "eulerPath(self, N, graph)" ], "initial_code": "# Initial Template for Python3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input().strip())\n graph = []\n for i in ...
eJy1VEsOwiAQdWE8B2HdmEGNC09iYo0L7cJN7aImJkbjIfRu7ryKbYGBKZJS1H5SOp/34M3Abfh4jQbNtXxWg9WZ7/PiWPIF4yLNqwd4wnh2KrJtme02h2NpvNc055eE0ZRJlcLqVNY3c9pkqlwG6tMTZKZAMB/x6oFy9cScy0T5KlwJCR6PkB7Qv/oH4tmRkLALmx3pDCFhj1m7AEKvb60p2A4UmkY6JiMbcRGRbIEds210BCfmtjGmAO2WUi2K+DGyIqZwMLGqUfsH16zxft9tf2u3msET70ZCYKgRG9UWciCPtw6xwbcv6hlI6MjS...
703,573
Convert String to LowerCase
Given a string s. The task is to convert characters of string to lowercase. Examples: Input: s = "ABCddE " Output: "abcdde " Explanation: A, B, C and E are converted to a, b, c and e thus all uppercase characters of the string converted to lowercase letter. Input: s = "LMNOppQQ " Output: "lmnoppqq " Explanation: ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1618996493, "func_sign": [ "static String toLower(String s)" ], "initial_code": "// Initial template for Java\n\nimport java.util.*;\nimport java.io.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReade...
{ "class_name": "Solution", "created_at_timestamp": 1618996493, "func_sign": [ "toLower(self , s : str) -> str" ], "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....
eJzFVk1zmzAQ7aG3/omMz5nOJGkuvRGs2G4weADnY0rbUWCJlcBChHC+pp3+iPb/dgE74zgWaVJnykkS0tvdt09v9PPtb3j3pv6Ov9Lg811HYF6qzseNzk6Aoxs1ydB1zAMvwD4kSXaUySQK0MmZzUVnc6MD1zmECqJvWalmB/P6lMzCiyLAHwFOqoNXzUGaZjkgF/Ww831zYyHiVoCfykL5zPMFnmnQz2mHgkLRjlUY2wGaWQRHXFJwC0BVMw1USL+u6o2Ek9DeamEV6G6A+2PL8nzDPAiwyw4hoSpkgEMRysxj7qEIgWAM1xexCAVP...
701,299
Maximum Occuring Character
Given a stringstr of lowercase alphabets. The task is to find the maximum occurring character in the string str. If more than one character occurs the maximum number of time then print the lexicographically smaller character. Examples: Input: str = testsample Output: e Explanation: e is the character which is having...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1619110365, "func_sign": [ "public static char getMaxOccuringChar(String line)" ], "initial_code": "import java.lang.*;\nimport java.io.*;\nimport java.util.*;\nclass GFG\n{\n\tpublic static void main (String[] args) throws IOException\n\t{\n\t BufferedR...
{ "class_name": "Solution", "created_at_timestamp": 1619110365, "func_sign": [ "getMaxOccurringChar(self,s)" ], "initial_code": "# Initial Template for Python 3\n\nimport atexit\nimport io\nimport sys\n\n_INPUT_LINES = sys.stdin.read().splitlines() # Ignore the first line\ninput = iter(_INPUT_LINES).__ne...
eJxrYJm6loUBDCKWARnR1UqZeQWlJUpWCkqGMXmJSjoKSqkVBanJJakp8fmlJVCpxJi8upg8pVodBTT1SckpqSTqqYIDHBqrcFqWmAzEKVCaRGsrKqsqK3DoqcBlY2JSUnIyOWGSlp6RmZWdk5uXX1BYVFxSWlYOtJ9Eg5KSSY4OGEgi1arEvETSIx8WqoRsNcSZEjBjley0AQx0eKhDQxx3kKcSNIZUncDIIiZt4w4KcrNDEpn5AeJmfBkYl1sTwVopivmkRHiiw5PwYLpjp+gBAI+Bm90=
703,420
Not a subset sum
Given a sorted array arr[] of positive integers, find the smallest positive integer such that it cannot be represented as the sum of elements of any subset of the given array set. Examples: Input: arr[] = [1, 2, 3] Output: 7 Explanation: 7 is the smallest positive number for which no subset is there with sum 7. Input...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public long findSmallest(int[] arr)" ], "initial_code": "// Initial Template for Java\nimport 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": 1615292571, "func_sign": [ "findSmallest(self, arr)" ], "initial_code": "# Initial Template for Python 3\n\ndef main():\n t = int(input())\n for _ in range(t):\n arr = list(map(int, input().split()))\n ob = Solution()\n ans = o...
eJyllE0OgjAQhV1wkJeuiekPIHoSEzEulIUbZAGJidF4CL2gO2/htEIAE2KmQBdNm2/mzcyDe/B8BzP3rF+02VzEsSjrSqwgVFbQEiFEfi7zfZUfdqe6ai51Vtzo8hpiSNC5wjimRjAlHff7suMYG0Yj9gMVDBukVBoGERawRTDp6Ks3QuqFSmgJIxHxMyf9hsd8nuqOkVDVKZb8cbtlQzDtZVq2wbmJrT35ztB+1nDfgoeJtaKO9qukjT32EN9NOXZjNjbwBI9O950TlQ2G6ES1zcqM5P5zkk7X3wZtH/MPcO+FcA==
710,283
Geek in a Maze
Geek is in a maze of size N * M. Each cell in the maze is made of either '.' or '#'. An empty cell is represented by '.' and an obstacle is represented by '#'. If Geek starts at cell (R, C), find how many different empty cellshe can pass through while avoiding the obstacles. He can move in any of the four directions bu...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1648717203, "func_sign": [ "public static int numberOfCells(int n, int m, int r, int c, int u, int d, char mat[][])" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n//Position this line where user code will be p...
{ "class_name": "Solution", "created_at_timestamp": 1648717203, "func_sign": [ "numberOfCells(self,n, m, r, c, u, d, mat)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n\n for tcs in range(t):\n n, m, r, c, u, d = [int(x) for x in input(...
eJztVs1OwzAM5sCNl7CS6xSlNFklngSJAgfogUvYoZOQ0KY9BLwvdrKk7SDVvB+GJuyqaZP2s+vms726/GyuLrzcPuDF3bt4cbN5K25AFLWzYOE6aO0UCQ3SDxK1uyMRExDN26x5apvnx9d52+EsaycWExiCT2EKJWoBxRogwAbcOG7Oj1oyGVMGKtBoTkMZIWTtZJA4o9JMBl5n0AsNeFCsyg5/bUMFRJWCdNQFruMW8KhQ0fk+aAp6X9RZP8ENHW5bHRShmDt/8DJ3txFl6NVIG88Nf8oA2REgonbwwvOAgJDXTI9o5xtUDSZliT6z...
702,930
Check if actual binary representation of a number is palindrome
Given a non-negative integer N. Check whether the Binary Representation of the number is Palindrome or not.Note: No leading 0’s are being considered. Examples: Input: N = 5 Output: 1 Explanation: The Binary Representation of 5 is 101 which is a Palindrome. Input: N = 10 Output: 0 Explanation: The Binary Representat...
geeksforgeeks
Easy
{ "class_name": "Sol", "created_at_timestamp": 1615292571, "func_sign": [ "int binaryPalin(long 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(System...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "binaryPalin(self, N)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input())\n for tc in range(t):\n n = int(input())\n ob = Solution()\n print(ob.bina...
eJxrYJnKwsIABhF/mRkYoquVMvMKSkuUrBSUDGPyzJV0FJRSKwpSk0tSU+LzS0sQUkq1Ogqoig1NSVFtTIpiCxyKDbCabEiSO0hzCEl+NDIlUTlJ4W1qSJJHzXEZjiMQwe4hKXAMTfH6Gas9QE/giwSsesAaSPI7zGWGeXiSB1a7jEwp8BiS/0j1I1w7OBrINMSCJK/HTtEDACVHPHc=
703,562
Red OR Green
Given a string of length N, made up of only uppercase characters 'R' and 'G', where 'R' stands for Red and 'G' stands for Green.Find out the minimum number of characters you need to change to make the whole string of the same colour. Examples: Input: N=5 S="RGRGR" Output: 2 Explanation: We need to change only the 2n...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1618600716, "func_sign": [ "static int RedOrGreen(int N, String S)" ], "initial_code": "// initial template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n // Position this line where user code will be pasted.\n public static vo...
{ "class_name": "Solution", "created_at_timestamp": 1618600716, "func_sign": [ "RedOrGreen(self,N,S)" ], "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 S = input()\n\n ob = Solution()\n ...
eJxrYJl6g5UBDCIuAhnR1UqZeQWlJUpWCkqGMXmGBjF5QVDg7h6Tp6SjoJRaUZCaXJKaEp9fWgJVaRSTVweUrNVRQNVuBNTuDgJBqACnQaY4DDIESgS5o0CcZpjjMgNoBE5NBrg14fY2Lk1GoEAjRxeeIMZnF25dhnjswu1CXLqMQf4izzL3mBgsyYmM2IBECCUhjOQQ/I4j35noqZXM5IrwKwGHkpOsQYZTEiZASWgsEExP+F2Bu5AwJNtjsBQSQ2kKIRgQMfjDi6wkDjMIEbBIRgIFgDgmhjgPxk7RAwAyReYA
701,595
Reverse a String
You are given a string s. You need to reverse the string. Examples: Input: s = "Geeks" Output: "skeeG" Input: s = "for" Output: "rof" Constraints: 1 <= |s| <= 10**4
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1617249096, "func_sign": [ "public static String reverseString(String s)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass Driver {\n public static void main(String args[]) throws...
{ "class_name": "Solution", "created_at_timestamp": 1617249096, "func_sign": [ "reverseString(self, s: str) -> str" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input())\n while t > 0:\n s = input()\n ob = Solution()\n print(ob.re...
eJytVMlOwzAQ5YD4jmnaY4Wa7uVUiUvFuQckipDjOHtsZ18QiI+A/8UJFLWHCa1gDnGkN28845k3b5cfd1cXrd3fqp+HZ83lMku1G9D0HSfaEDRWSkZTZj6JLP2GyI6/7rj2MoRj/5hQRkmMsL5RhNtb9weD/rqHkPcwwiYGNZllO67nByEXMoqTNMuLsqqReHVVFnmWJnEkBQ8D33Md22ImNbDacAL2SGhKWA0QEg4EZNAelHASgFTfEL1CEYgE5U+oYih/2R4hYFXo48l0Nl8sVyMk5Gi1XMxn08lYx7JUZiijykxlSJwGalwa14aC...
701,419
Count ways to N'th Stair
There are n stairs, and a person standing at the bottom wants to reach the top. The person can climb either 1 stair or 2 stairs at a time. Count the number of ways, the person can reach the top (order does not matter). Examples: Input: n = 4 Output: 3 Explanation: You can reach 4th stair in 3 ways. 3 possible ways a...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1617868826, "func_sign": [ "Long countWays(int n)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) {\n\n // taking input using Scanner class\n Scanner sc = new Scanner(Sy...
{ "class_name": "Solution", "created_at_timestamp": 1617868826, "func_sign": [ "countWays(self, n)" ], "initial_code": "# Initial Template for Python 3\nimport atexit\nimport io\nimport sys\n\n# Contributed by : Nagendra Jha\n\nif __name__ == '__main__':\n test_cases = int(input())\n for cases in ra...
eJylU0EKwjAQ9NCHlJyLZFsj1JcIRjxoD15iDy0IUvER+jxvPsQ0TbSVTLS4lxSW2Z3ZmV6i2yOamFre9cfqxPaqrCu2iBlJRVwqlsSsOJbFtip2m0Nd2e5cqrNuNkk8hKQCQigDGIHXpGgPcQwShEEBFIcwLAldAQsCiGw0IjcVkMONWniI8C10ecVxc47WMYT1ZyIoESajOyUpKenLhBDXl/NjSNOAeJ/HRwOTgtn1CftPqp0asAX/E91u0X9GauqFwhExr3Qx06Js/3cDcgsxMW9nedx8BxkSnjnG6+v0CRWvjZo=
703,054
Jumping Caterpillars
Given n leaves numbered from 1 to n.A caterpillar at leaf 1. The array contains the jump power of the caterpillar. The caterpillarjumps from leaf to leaf in multiples of arr[j], j is specific to the caterpillar. Whenever a caterpillar reaches a leaf, it eats it a little bit. You have to find out how many leaves are lef...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int uneatenLeaves(int[] arr, int n)" ], "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": [ "uneatenLeaves(self, arr, n)" ], "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 arr = list...
eJzFlL1OAzEMxxkQz2HdXKE4dj7MK7AxIVHEAB1Yjg6thIRAPAS8L3ZzS9U6PXUhkq27xPnJ/9jJ9+Xv3dXFbtzf6sfDx/A6rreb4QYGXI4YdAAWQIFIEGWaGhYwrN7Xq+fN6uXpbbuZdtRIvBy/luPwuYBDEigHAakB25xDyuyBkoEIgQowAhNwaZMOiamWTk4BIqT9xOYojZRjTylBBgGMgAmw9qXm7JBKsvQSJD05xdiPodVYTRdbiMMt0QKOgkUHiBRjapbBlAe0rzitOkyR5MmuJtu4O/3q0Fw0R23Vy1My9QvUjkGB6qI5Msfm...
707,364
Split Array Largest Sum
Given an array arr[] of N elements and a number K., split the given array into K subarrays such that the maximum subarray sum achievable out of K subarrays formed is minimum possible. Find that possible subarray sum. Examples: Input: N = 4, K = 3 arr[] = {1, 2, 3, 4} Output: 4 Explanation: Optimal Split is {1, 2}, {3}...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1620401189, "func_sign": [ "static int splitArray(int[] arr , int N, int K)" ], "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...
{ "class_name": "Solution", "created_at_timestamp": 1620401189, "func_sign": [ "splitArray(self, arr, N, K)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N, K = map(int, input().split())\n arr = list(map(int...
eJy1lM9KxDAQxj0IvsZHzoskk07a9UkEVzxoD17qHrogiOJD6Ct48x3NJFRxdfpnoy18Xdjky8xvZvJ8/Pp+cpSe87f44+LB3HbbXW/OYNymcxCx8dl0ZgXT3m/b6769ubrb9cOq/O9TXPC4wt52C04m+6/qRrqTszkUkIgXqURYJIjUIo3IWqQgboaXuAkeFRgBNRqsIVHE6AnOw1VwrLr7oFjTkEi0a6JtiPZVPIYSmJ8H6vF75QQGJVDCSTAJJYGkOgWVQ40qlS/R/P4Z4+r03Fnim/XqLaJF20jRONU9libnT5wZeE4cVFNmtRcI...
702,802
Ishaan's Internship
Ishaan wants to intern at GeeksForGeeks but for that he has to go through a test. There are n candidates applying for the internship including Ishaan and only one is to be selected. Since he wants to qualify he asks you to help him. The test is as follows. The candidates are asked to stand in a line at positions 1 to n...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "int getCandidate(int n, int k)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\npublic class GFG\n{\n public static void main(String args[])\n {\n ...
{ "class_name": null, "created_at_timestamp": 1615292571, "func_sign": [ "getCandidate(n, k)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n\n for _ in range(t):\n n, k = map(int, input().split())\n\n print(getCandidate(n, k))\n ...
eJylkz1uwzAMhTvkIITmoKB+SEk5SYCo6NB66OJmcIAAQYscIr1et9yjtusGNtDnwXmTB33kI/l8Xn1dVw+9tt/tx+5k3ur9oTEbMrbUljuRK7VZk6mO++qlqV6f3w/N8EZFvJb6s33wsaYpnDuRZQj31QEsfWPBrKgTwA6uPYQlc8gIdj4IRci6wBYNnKLKwmVJ8M5SwPOqTwGwsRMpZIOqoL5Jg2NKkPUuakKeO1GemVfRqm5tMQ078z22R/AkKaXMmkGjjMrh20WG67/F3JayIOkDjn8Tz5D9tU0Lb/9H8z03mN2aZBf538hPb9in...
703,713
Extract the Number from the String
Given a sentence containing several words and numbers. Find the largest number among them which does not contain 9.If no such number exists, return -1. Examples: Input: sentence="This is alpha 5057 and 97" Output: 5057 Explanation: 5057 is the only number that does not have a 9. Input: sentence="Another input 9007" O...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "long ExtractNumber(String sentence)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nimport java.util.regex.*;\n\nclass GFG {\n public static void main(String args[]) throws IOExc...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "ExtractNumber(self,sentence)" ], "initial_code": "t = int(input())\n\nfor _ in range(t):\n S = input()\n ob = Solution()\n ans = ob.ExtractNumber(S)\n print(ans)\n print(\"~\")\n", "solution": "import re\n\n\n...
eJy1VcFunDAQ7aFSf2PEmUSGZRecD6iUHNJLpVZqqoqF2cXqYq9sIxpVrfoR7Y/11r/p2LBRosRkiRJOyIPfe37zxvx6/effm1f++fiXXj59j4TcdzY6gyi5ku8bhL0WFUJfGihynsO6syBVD8KCoCXGrmQUQ4Tf9lhZrL+ozo77fe0nlX/EcBf2A8JGdbIGDhJ7MLRVoAEhIWVpMlJIHBcWQYah+CCFU94LKYXcguzaNWoDPWp0gDFkLIuhJAErtgqi+9qD4DxjS3d6qSxYIqpUjV51smS0HkSkcgDxrdKERJBulxYtShtDyknqgi8G...
707,054
IPL 2021 - Match Day 6 - Semi Final
IPL 2021 knockouts are over, teams MI, CSK, DC, and RCB are qualified for the semis. Examples: Input: s = "ababcababcd" Output: ab*c*d Explanation: We can encrypt the string in following way : "ababcababcd"-> "ababc*d" -> "ab*c*d" Input: s = "zzzzzzz" Output: z*z*z Explanation: The string can be encrypted in ...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1618213837, "func_sign": [ "public String compress(String s)" ], "initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*;\npublic class Main {\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader ...
{ "class_name": "Solution", "created_at_timestamp": 1618213837, "func_sign": [ "compress(self, s)" ], "initial_code": "# Initial Template for Python 3\nt = int(input())\nfor _ in range(0, t):\n s = input()\n obj = Solution()\n ans = obj.compress(s)\n print(ans)\n print(\"~\")\n", "solutio...
eJzdVtsOgjAM9cF3fwH3ZBpj4qtfYiLGyMQrDlRQwGj8CP1fAY23UAYDnbp2hKTbeklP20P5VKuUotWuBj+dLZkwy7FJSyFNlfVJXSG6a+nU1gc907Gvor7K9ioju7rycl4TJ0yVBjdGtVJhRrVSgOjzBk/FI8ENhevJI8Rs14NHRgz3pS7EdB/uhNhtmGwkayNWhyKI+eDoGejD0XgynRlzZlqL5cp21hvX8z8lwTGIXIigicgk4DUVJYA6XGhFzbEwlXAhGaVNOEg3DnZh3SdD76Aa5b1WrLeBo80/8DNne84TphQlNCfApFR2gIvh...
713,968
Shortest Path Using Atmost One Curved Edge
Given an undirected connected graph of n vertices and list of m edges in a graph and for each pair of vertices that are connected by an edge. Examples: Input: n = 4, m = 4 a = 2, b = 4 edges = {{1, 2, 1, 4}, {1, 3, 2, 4}, {1, 4, 3, 1}, {2, 4, 6, 5}} Output: 2 Explanation: We can follow the path 2 -> 1 -> 4. This giv...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1675767177, "func_sign": [ "static int shortestPath(int n, int m, int a, int b, ArrayList<ArrayList<Integer>> edges)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException...
{ "class_name": "Solution", "created_at_timestamp": 1675767177, "func_sign": [ "shortestPath(self, n, m, a, b, edges)" ], "initial_code": "# Initial Template for Python 3\n\nfrom heapq import *\nimport sys\nsys.setrecursionlimit(10**6)\n\nif __name__ == '__main__':\n t = int(input())\n for _ in rang...
eJzFlk1u20AMhbvooscgtDYKk/Mn5yQBOkUXjRfdKFnYQIAgQQ6RHC27HKZ8pKZuAE8jB20jA9aMhhx+fKTGvv/4+Pzpg13nTzr4cjP8mK72u+GMBq4Tr4mlToFGHZNQIl7XSShQpIDnUR/mOkVdCaQOiTKNpC6Zin7UpmBOsU4jbXRRbTa6iY4FWyY4wk3nWBM4YWlY0bC9vtp+320vvl3udzOTctzp4u2KXoImKnBOjinYE5RC4pSMJ9HCIS1LQGATPVzQBQPoxA2duIU2cM4eNx/iRo9rmyNuaeokLOWWJqtNdK/k7sFs+iTcIRmt...
702,664
Adding One
Given a non-negative integer(without leading zeroes) represented as an array arr. Your task is to add 1 to the number (increment the number by 1). The digits are stored such that the most significant digit is at the starting index of the array. Examples: Input: arr[] = [5, 6, 7, 8] Output: [5, 6, 7, 9] Explanation: 5...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "Vector<Integer> addOne(int[] arr)" ], "initial_code": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int t = Integer.parseI...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "addOne(self, arr)" ], "initial_code": "# Initial Template for Python 3\ndef main():\n T = int(input())\n\n while T > 0:\n # Convert input to list of integers\n a = list(map(int, input().strip().split()))\n ...
eJzdVsEKwjAM9eDdXwg9i7ha5+qXCCoedAcv08MEQQQ/Qv/Qmz9hNvQw17hYzRT3KOtG0/S9pE0PzdOl1cif0Rk7451aJutNqoaggkliIYIBhNAHAz3QEEAXmP9UG1S8XcfzNF7MVpv0Nqn/jLgctW9DcYHZUFEQNKT9OslaEMaXyCLcsdUYeoMpEGIqRLhA1OWT/0i6kn4tRVZc4zrwvQyqAcSmlD8OiaOvnGp8xzxrgjFLLJIxx1q7HEfAAuGYZ23dUrNASs2Bk7H3vmEP/KX69kSewod+UWhd6Pdkj1/jZcbeVpzICsfUeFkR+f1u...
702,781
Count Occurences of Anagrams
Given a word patand a text txt. Return the count of the occurrences of anagrams of the word in the text. Examples: Input: txt = forxxorfxdofr pat = for Output: 3 Explanation: for, orf and ofr appears in the txt, hence answer is 3. Input: txt = aabaabaa pat = aaba Output: 4 Explanation: aaba is present 4 tim...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1619175296, "func_sign": [ "int search(String pat, String txt)" ], "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 Exception {\n...
{ "class_name": "Solution", "created_at_timestamp": 1619175296, "func_sign": [ "search(self,pat, txt)" ], "initial_code": "# Initial Template for Python 3\n# Driver code\nif __name__ == \"__main__\":\n tc = int(input())\n while tc > 0:\n txt = input().strip()\n pat = input().strip()\n ...
eJy1VN1OgzAU9sL4HITrxbjpjT6JiTULlALl51AYLQWj8SH08bzzQexgEkk8c+uwTZrTtP369fQ73+v5++fFWd/uP0zw8ORyELJ27xx3ScDzacBCM0YxT9Ish0IQEGVFwF04LtOC0ZoF60LWuzNXBF7M4vPCmQJ1Xde2rda6aRqllJTSgHve0TgDoS2b3yICuu0sMNFOYBgRxNUNBun5PqVBwFgYRlEcc54kaZpleU4AoDiaYvpH63egqNcY7PY/y2pTS9WYxE0m/ZfNmcq+DzvwfN5i8ml1o2S9qUpRQJ6lCY+jkAXU7zVkBIBCLhHE...
709,901
Longest Possible Route in a Matrix with Hurdles
Given an Nx Mmatrix, with a few hurdles(denoted by 0) arbitrarily placed, calculate the length of the longest possible route possible from source(xs,ys) to a destination(xd,yd) within the matrix. We are allowed to move to only adjacent cells which are not hurdles. The route cannot contain any diagonal moves and a locat...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1650428085, "func_sign": [ "public static int longestPath(int[][] mat,int n,int m,int xs,int ys,int xd,int yd)" ], "initial_code": "import java.io.*;\nimport java.util.*;\nclass IntArray\n{\n public static int[] input(BufferedReader br, int n) throws ...
{ "class_name": "Solution", "created_at_timestamp": 1650428085, "func_sign": [ "longestPath(self,mat : List[List[int]],n : int, m : int, xs : int, ys : int, xd : int, yd : int) -> int" ], "initial_code": "class IntArray:\n\n def __init__(self) -> None:\n pass\n\n def Input(self, n):\n ...
eJzVVr1OwzAQZmDjJU6eC7pr0ojwJEgYMUAGFtMhlZAQCDYeAN4Xx26D7fiCA7FakiHO5fx99++8Hn++nxyZ6/JNL66exL1ab1pxAYKkKqCQCgFhCUupCPTdPdA+zJtYgGge181t29zdPGza7eZSqhf98XkBPuIKVhaxhNJioIPqIFvpVgboSRnOc4bTUHWcxp0epUN2+SzbGAEhw0B6J1qOGmrHVvB8CW8aauK3Zb1WsiaDmc5OrJCJSFExEamgspwm4QG+ZwH63kRcowBgcnYc//WCBTilJADeAh4gqI9hMvCfC6dGpJ8DuJsD5Ld5...
702,953
Check if a given string is a rotation of a palindrome
Given a string s, check if it can be rotated to form a palindrome. Examples: Input: s = aaaab Output: 1 Explanation: "aaaab" can be rotated to form "aabaa" which is a palindrome.
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "int isRotatedPalindrome(String s)" ], "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...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "isRotatedPalindrome(self, s)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n T = int(input())\n\n for _ in range(T):\n s = input()\n ob = Solution()\n answer = ...
eJxrYJn6kYMBDCJeARnR1UqZeQWlJUpWCkpGMXmJSclJiUAKBJKUdBSUUisKUpNLUlPi80tLoMoMY/IMYvKUanUUkPQax+QVJSanJicWxeQBiVQgB2RMEh5DIAjNHKBIRUVlZQVubWgaTGLyqvAAsJdSUtPSM2LykoDuARqP13QDHO4Chk1OallqTkxeXn5+Hl5PYfookWjfgBTjCjLMQAepJtHsZFzqsZoOCit8mCS7Y2KAtqNHFxGWwNXiTGNkRDX2wKSFEyuo60Z0q0HOpka0xIDYpHg8GYvPIUkMnCxpGQbUcHPiQDmapomrihqp...
706,459
Rank The Permutations
Given a string, find the rank of the string amongst its permutations sorted lexicographically.Example 1: Examples: Input: S = "abc" Output: 1 Explanation: The order permutations with letters 'a', 'c', and 'b' : abc acb bac bca cab cba Input: S = "acb" Output: 2 Constraints: 1 ≀ |S| ≀ 18
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public long findRank(String S)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG\n{\n public static void main(String[] args) throws IOException\n {...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "findRank(self, S)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n str = input().strip()\n obj = Solution()\n ans = obj.fin...
eJyVkt0KgjAUx7vwQWTXFnMLN3uPIGgR7sPUyrxQCKPoIep9E0Oii6OcXQ12Dr//x57eW3mz/mzW3WV7I3lZNTVZ+SRUZUICn7hr5Uzt7P7S1L+nhyrJPfD/51vsPARgwEKCJSQauaDRkrSxLj1kORJU5NkhddaAQB4xKSmdwhZI7vl0nERHjAnKKExvwao5pLeXiw0p0YNNDflcRoyD0O+2UhmwDPnrEgLDCRmYChxLPKqwGOlRQOb6IqealCIUImaSg6KHj4RuxlilXAr++/lgefdafABHLW9n
705,108
A Simple Fraction
Given a fraction. Convert it into a decimal.If the fractional part is repeating, enclose the repeating part in parentheses. Examples: Input: numerator = 1, denominator = 3 Output: "0.(3)" Explanation: 1/3 = 0.3333... So here 3 is recurring. Input: numerator = 5, denominator = 2 Output: "2.5" Explanation: 5/2 = 2...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615931384, "func_sign": [ "public String fractionToDecimal(int numerator, int denominator)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG\n{\n public static void main(String[...
{ "class_name": "Solution", "created_at_timestamp": 1615931384, "func_sign": [ "fractionToDecimal(self, numerator, denominator)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n numerator, denominator = input().split()...
eJztm0uOpkcRRRmwkFKPGgm1Il+RmeyAHSABYgAeMDEeGAkJITFgCbBfzolqJCz6Nx4i9GFsd1X9+Yq8cePGzfJff/yPv/38R/W/X/yFP/zyzx9+//U3f/z2w8/ePrRffd372/7w07cPX/3pm69+++1Xv/vNH/747eefjk8f2+xn7Z/86usPf/np23cHtvuWLwe2j/nlQRHxNsZ4vWLE+OLI/db6i1HxaZ2PXx7V5tt6Map/Ol8ace/bjhdD2qf5vRFZ8dZexeR+Gnt9cVQf8+3e+3LNj32sL6/31gnny6Dwsy8vuL2DF8NW5qdXd/dW...
702,029
Search in a 2D Matrix
Given amatrix[][],with the following two properties: Examples: Input: matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 3 Output: true Explanation: the numner 3 exists in the matrix. Input: matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 13 Output: false Constraints: 1 <= number of rows, number of...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1729521069, "func_sign": [ "public boolean searchMatrix(int[][] mat, int target)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\npublic class Main {\n public static void main(Strin...
{ "class_name": "Solution", "created_at_timestamp": 1729521069, "func_sign": [ "searchMatrix(self, mat, target)" ], "initial_code": "if __name__ == '__main__':\n t = int(input()) # Number of test cases\n for _ in range(t):\n n, m = map(int, input().split()) # Dimensions of the matrix\n ...
eJztlt2K1EAQRr3wyqdocr2RdKd/fRLBiIiOIEhcdAYEUXwIfTHvfBvPV73CwjI6k7kRMdCd2U2dnlT1qd79cv/bjwf37Hr8nQ9PPg6v1+vDfnjkhjFN07IOV27YfbjevdjvXj57e9jfPBw+XblbsX5Zk0vLOvqJy42Ny+Zqc7E585xbsh+izbPNwWbfHxtdja5GV6Nrp6vR1ehqdDW6droaXYwuRhejS6dLOprQq+dv3u+W9TMBd1Lzk/OTbpMLjJkRGdTHZUZhVEabFKeieYV6xXoFe0V7hXvFewFehG99SZBgqwsJQoKQICQICUKC...
713,586
Length of the longest subarray with positive product
Given an arrayarr[]consisting of nintegers, findthe lengthof the longest subarray withpositive (non zero) product. Examples: Input: arr[] ={0, 1, -2, -3, -4} Output: 3 Explanation: The longest subarray with positive product is: {1, -2, -3}. Therefore, the required length is 3. Input: arr[]={-1, -2, 0, 1, 2} Output...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1673952636, "func_sign": [ "int maxLength(int arr[], int n)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.io.*;\nimport java.lang.*;\n\nclass Geeks\n{\n public static void main(String args[])throws IOException\n ...
{ "class_name": "Solution", "created_at_timestamp": 1673952636, "func_sign": [ "maxLength(self,arr,n)" ], "initial_code": "def main():\n T=int(input())\n while(T>0):\n \n n=int(input())\n\n arr=[int(x) for x in input().strip().split()]\n \n ...
eJxrYJkaxcIABhHBQEZ0tVJmXkFpiZKVgpJhTB4QGcTkKekoKKVWFKQml6SmxOeXlkDlgTJ1QMlaHQUMTYY4NRni1qSLWxcuq4yA7lMg3YVAbYZ4tOFyoxHIjeRah9tzRnitwxMquDQaQ9yJx0pcPjSB6iTDXtzBgmmNLtFW4QpSBXjiJNGTeOzCmijRnEmybeSGCVLi1jUkPXzABpKih4A9eNxLwJbYKXoAD8ZcMQ==
712,225
Burst Balloons
You are given Nballoons, indexed from 0 to n - 1. Each balloon is painted with a number on it represented by an array arr. You are asked to burst all the balloons. If you burst the ithballoon, you will get arr[ i - 1 ] * arr[ i ] * arr[ i + 1] coins. If i - 1, or i + 1 goes out of the bounds of the array, consider it a...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1731737459, "func_sign": [ "public static int maxCoins(int[] arr)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.math.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] a...
{ "class_name": "Solution", "created_at_timestamp": 1731737459, "func_sign": [ "maxCoins(self, arr : List[int]) -> int" ], "initial_code": "class IntArray:\n\n def __init__(self) -> None:\n pass\n\n def Input(self, n):\n arr = [int(i) for i in input().strip().split()] # array input\n ...
eJytVMFKAzEQ9SD05jc89iwymSSTjF8iuOJBe/Cy9tCCIIofof/rZLeKhc7aii0bhuzy5uW9N3k7/ThbnIy/q4UV18/dw7DarLtLdKEfcj8oikASOEBLd45u+bRa3q2X97ePm/X2SxFNmvrhtR+6l3PsYkg/BASi3cdBYgoUiRyoYC9iBhunimRFRBajta2DhxpYhEkc1GrAAZxg0CkgKySiMKoLRyWQRI8k2xMbn5gaMWMopRGuCrWTc9vP4gnAKaTqCcD2YjquYVgHAzbUbNS5GTQ12YrB285WT5uuPDmVGf9CC4HC7P9l8dCVzNIw...
705,696
Biconnected Graph
Given a graph with n vertices, e edges and an array arr[] denoting the edges connected to each other, check whether it is Biconnected or not.Note: The given graph is Undirected. Examples: Input: n = 2, e = 1 , arr = {0, 1} Output: 1 Explanation: 0 / 1 The above graph is Biconnected. Input: n = 3...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int biGraph(int[] arr, int n, int e)" ], "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 Bu...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "biGraph(self, arr, n, e)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n n, e = map(int, input().split())\n arr = list(map(int, i...
eJxrYJn6lpUBDCKeARnR1UqZeQWlJUpWCkqGMXlGCkDCAEQo6SgopVYUpCaXpKbE55eWINTUASVrdRRQNRorGIM1AqEREBqQbIAJqgHGOA0wwGmACYoBQEi6K0wxDTEh2SWmCqYYhgAh6a4xw26QKckuMlMww2oQEJLuKkMDBUtcpgEtUjAHQgsgtCTZmUCTDQ2IMhoIqRW5JIYmbmsxLUTkJhBNejATHxhg9WRFJUkBjjuscNmACAL8aZC8MILHKIX5FSNdkBc2pKcm1JKTnKITajMebUq1sVP0AFpfpys=
712,574
Print Longest Increasing Subsequence
Given an integer n and an array of integers arr, return the Longest Increasing Subsequence which is Index-wise lexicographically smallest.Note -A subsequenceS1isIndex-wiselexicographically smallerthan a subsequenceS2if in the first position where S1 and S2 differ, subsequenceS1has an element that appearsearlier in the ...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1668705304, "func_sign": [ "public ArrayList<Integer> longestIncreasingSubsequence(int n, 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 m...
{ "class_name": "Solution", "created_at_timestamp": 1667710061, "func_sign": [ "longestIncreasingSubsequence(self, N, arr)" ], "initial_code": "# Initial Template for Python 3\n\n# Position this line where user code will be pasted.\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t)...
eJztmc1uXEUQhVnwIKVZR6ir/5snQYoRC/CCjcnCkSIhUB4i7LPLa+Z8NROEldyJ7Sh4Yo/lxdxx3e6qc079dPv19/+8s+/i56e3+vD8z93vVy9eXu9+tJ1fXHm6uGrmNq1Yt2HVsi3j290z212+enH56/Xlb7/88fL6wzsHQ4zs4upvGf71zG4umvV60VJdi01re1vXS17NtZubF/Nurm+meTZflre33C81D8vsl/j3Zd7c9KMRoGVCKsWyW0tW3Xqyqa+bZXk4LE/LMkhWFFzGslQrzUq3MqwImmX1CCKxwx1X23K5AF0iUIVVwkm9...
704,354
Trail of ones
Given a number n, find the number of binary strings of length n that contain consecutive 1's in them. Since the number can be very large, return the answer after modulo with 1e9+7. Examples: Input: n = 2 Output: 1 Explanation: There are 4 strings of length 2, the strings are 00, 01, 10, and 11. Only the string 11 ...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int numberOfConsecutiveOnes(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 Buffe...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "numberOfConsecutiveOnes(ob,n)" ], "initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n\n ob = Solution()\n print(o...
eJydVEFuwyAQ7KH9h8U5imAXMOQlkUrVQ+tDL24U2VKiKFEekfy3gJ1GSCyOs/bBEswyszPm/Hrdv73EWm/9x/uB/bSbvmOrignXgmvZomLNbtN8dc3352/f3RdPfvG4qFIEkggkEIo+wxIQwUORuBqM1taEHVm4DUXzRA0SFarC4SRYo1BCa1kiToO5NRa4qHNoiG5MKB9cKeqH6NHECCKwOAiMxo16plgNPqbypkyC2/uQ5EwQ5zBUhtfhIZulVMg+4AVqiYbqM4q6J2G+rJHJLYguNnmaUOgh6LkYJbnVymQTmZmLG26Ap9gkwfQ7...
700,469
Sort a stack
Given a stack, the task is to sortit such that the top of the stack has the greatestelement. Examples: Input: Stack: 3 2 1 Output: 3 2 1 Input: Stack: 11 2 32 3 41 Output: 41 32 11 3 2 Constraints: 1<=N<=100
geeksforgeeks
Medium
{ "class_name": "GfG", "created_at_timestamp": 1615292571, "func_sign": [ "public Stack<Integer> sort(Stack<Integer> s)" ], "initial_code": "import java.util.*;\nimport java.util.Scanner;\nimport java.util.Stack;\n\nclass SortedStack {\n public static void main(String[] args) {\n Scanner sc = ne...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "Sorted(self, s)" ], "initial_code": "if __name__ == '__main__':\n t = int(input())\n for i in range(t):\n n = int(input())\n arr = list(map(int, input().strip().split()))\n ob = Solution()\n o...
eJy1VMtKxEAQ9CD4G0XOi0z3vBK/RDDiQffgJXrYBUEUP0L/yps/ZE9vCLtmOxtfyQTCzFRVd3XPvBy/fZwc6XP+Lj8Xj9Vtd79eVWeofNtFGQjwYFDbhbYjB3bwDsG1XZKpCPYghg9oEKoFquXD/fJ6tby5uluveiYSvBeeiLZ7FpAyCI+wbSYEKwRCI2Sh31U9LbAVDbdd3XYsVLqLA1i0EziD6xJY+Rwah9ohOySHWMIcpIzYuFaKpHRBqUWANjFspVvYkjLXqlLE9sUpPlEsH0gyUm+ISqYNamQkDIYeNCvJ/lpwAi4UrHRCahqU...
703,392
Merge two binary Max heaps
Given two binary max heaps as arrays, merge the given heaps to form a new max heap. Examples: Input: n = 4 m = 3 a[] = {10, 5, 6, 2}, b[] = {12, 7, 9} Output: {12, 10, 9, 2, 5, 7, 6} Explanation:
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int[] mergeHeaps(int[] a, int[] b, int n, int m)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\nclass GFG {\n \n public static boolean isMerged(i...
{ "class_name": "Solution", "created_at_timestamp": 1624248285, "func_sign": [ "mergeHeaps(self, a, b, n, m)" ], "initial_code": "# Initial Template for Python 3\n\ndef isMerged(arr1, arr2, merged):\n if len(arr1) + len(arr2) != len(merged):\n return False\n arr1 += arr2\n arr1.sort()\n ...
eJztmM+OHDUQxjnwFlxKe46QXXZ12zwJEoM4QA5cBg6JhIRAPAA34H35fdUmgUhLZoZdkSi72naPqtvlqu+rfzO/fPzHb598lH+f/8qHL368+/b8/csXd5/ZnZ/OYXE6t2JerBYLQ+Rhlf9mtdo4nTfbTudais1io9hebOPFcjrPsBG2h20oCesountmd89/+P751y+ef/PVdy9frHPq6fwzOnK9++mZ/dOEqqPXEdPmsLnb3Az1s9tsNt0me3X8tDFs7DY2HT26jWbDbfC4utVUVmQdDgVqcQVjcQ+HdmvGOybLed557nKVjbGZD6vd...
703,908
Celsius to Fahrenheit Conversion
Given a temperature in celsius C. You have to convert it in Fahrenheit. Examples: Input: C = 32 Output: 89.60 Explanation: For 32 degree C temperature in farenheit = 89.60 Input: C = 25 Output: 77.00 Explanation: For 25 degree C temperature in farenheit = 77. Constraints: 1 <= C <= 100000
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static double celciusToFahrenheit(int C)" ], "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 Buffe...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "celciusToFahrenheit(self, C)" ], "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(...
eJytU8tOwzAQ5IDEF3DjUOVcRfvwxjZfgoQRB+iBi+mhlSohEB8B/4vj1Elbxa4rkUs3bXdmZ3b2+/r37uYqPg+3oXj8aN78ertp7heNOM/kPIVPBHDeWuu8QHia5aJZ7darl83q9fl9u9k3GNt24X9fzmvdwlARUirRMLQ01BaAxx+az+XigJedD99jT68zTFOv2FRZk9hP8FSYQvMwesCNavIihLhVaciJh7k1SUZh9uAXUuBS0mmTYSAZGQyRUHo5geqieYG5V6UEe62hYogytOQlKORkRWcgTWrUJAGsGg1UB2qQJa+tdy63jxF6...
702,962
Common Subsequence
Given two strings a and b. Checkwhether they contain any common subsequence (non empty)or not. Examples: Input: a = "ABEF" b = "CADE" Output: 1 Explanation: Subsequence "AE" occurs in both the strings. Input: a = "ABCD", b = "EFGH" Output: 0 Explanation: There's no common subsequence in both the strings.
geeksforgeeks
Easy
{ "class_name": "Sol", "created_at_timestamp": 1615292571, "func_sign": [ "Boolean commonSubseq(String a, String b)" ], "initial_code": "\nimport java.io.*;\nimport java.util.*;\nclass GfG\n{\n public static void main (String[] args)\n {\n \n Scanner sc = new Scanner(System.in);\n ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "commonSubseq(self, a, b)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input())\n for tc in range(t):\n a, b = input().split()\n ob = Solution()\n if ...
eJzFVctOhDAUdWHibzRdT4xu3VFa3u83qHGhLNzgLJjExJj4Efo57vwwr0KGKTMwlEg8G5pCzz09Pbe8nX58nZ38IvuEwfULfqzWmxpfIXx5U0lEpkxRNd0wLdtxPT8IozhJs7xAw6/wCuHyeV3e1+XD3dOm7ujw6wr1CiBRmouDNMM6izxLkzgKA99zHdsyDV1TFUZlIgnp5IEIjzlaeamgdF98ty0RrdxCjhLBpNCud2nQ7NOxHZLIWQHeg/UUea4e51HAUl8KaWNEkckJcWwRbX7KgiiPdddreUOpZUHtczvffSp65D9nKwMogAEU...
702,779
Count pair sum
Given two sorted arrays arr1 and arr2 of distinct elements. Given a value x. The problem is to count all pairs from both arrays whose sum equals x.Note: The pair has an element from each array. Examples: Input: x = 10, arr1[] = [1, 3, 5, 7], arr2[] = [2, 3, 5, 8] Output: 2 Explanation: The pairs are: (5, 5) and (7, ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int countPairs(int arr1[], int arr2[], int x)" ], "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[]) ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "countPairs(self,arr1, arr2, x)" ], "initial_code": "# Initial Template for Python 3\nimport io\nimport sys\n\n# Contributed by : Nagendra Jha\n\nif __name__ == '__main__':\n test_cases = int(input())\n for cases in range...
eJztVkuOEzEQZcGSQzxlPUIul+tjToJEEAvIgk2YRUZCQiAOAVdix52obrt7EkIDCRnNgnErfpV2ubp+ft2fH3/9/uTROJ5/C+HFh9Xb7fXNbvUMK1pvKY1jvZV9jIXVFVab99eb17vNm1fvbnZ9S2h8isWPV/jZTvxwdK23FUfXonFatj65WduIW8tWfm9k3DpZOdsEGAKLaCiiZJCADFSRCZmRBdmQKzgUGSxgA1cUQmEUQTGUCiFI2BGIQSqUoAwVqEErjGAMi8cYrMIJznCBGzyySKiMKqjhRUSSUaBwUAJlUAEpyJETckYuyIrs...
703,472
Construct binary palindrome by repeated appending and trimming
You are given two integers n and k. Your task is to create a palindrome of length n using binary numbers (0s and 1s) of length k that starts with 1. You can repeat the binary number as many times as you need, and you are allowed to remove any zeros from the end of the final palindrome. Examples: Input: n = 5, k = 3 Ou...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1713950908, "func_sign": [ "public static String binaryPalindrome(int n, int k)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n BufferedReader br = new B...
{ "class_name": "Solution", "created_at_timestamp": 1713950908, "func_sign": [ "binaryPalindrome(self, n : int, k : int) -> str" ], "initial_code": "if __name__ == \"__main__\":\n t = int(input())\n for _ in range(t):\n n = int(input())\n k = int(input())\n obj = Solution()\n ...
eJzs1EFqpOcVhtEMspDiH2tgOenE7kVkHEiBBt010KSkQQkETTdeRVaVRaUj0kvw1eXxORgsygVP8V1e//bnf/77H//507++HI/X55fb8fF03J+v9z+9efvjuDsdl9fny6fb5fPD08vtx7d++t3da2hoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGho...
702,910
Sort The Array
Given a random arrayarrof numbers, please return them in ascending sorted order. Examples: Input: arr[] = [1, 5, 3, 2] Output: [1, 2, 3, 5] Explanation: After sorting array will be like [1, 2, 3, 5]. Input: arr[] = [3, 1] Output: [1, 3] Explanation: After sorting array will be like [1, 3]. Constraints: 1 ≀ arr.siz...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1728621107, "func_sign": [ "void sortArr(int[] arr)" ], "initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(Syst...
{ "class_name": "Solution", "created_at_timestamp": 1728621107, "func_sign": [ "sortArr(self, arr)" ], "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().strip().split()))\n obj = Solution...
eJy9VbFu3DAM7dAlWz7hwXMQ2JJs2fmSAr0iQ3tDl2uGCxAgSJCPSP43Ip+M46Wlrr2hHGjJIt8jJZF6+fx2efFJ5ctFGXx97H7u7u733Q26YbNbRDCLIItgEsEogiSCKIIggkEEfXeFbvtwt/2+3/64/XW/r4B9Xact/YhBPGKTh5zk3+yeN7vu6QrHwY2ImDEhYEHGgNQiLlaFDIWk2BZgD3QIMY0YUwwDpjwvPZY5T4UqjVNGGaWSq0wgw4Bq7RDXVRCVfkSqDIpBHmKTzQuuFynJjPrl7shPZPmDINoJZaChmlR/Oh1QysQjPuvc...
701,989
Rotate by 90 degree
Given a squarematrix[][]. The task is to rotate it by 90 degrees in an clockwise direction without using any extra space. Examples: Input: mat[][] = [[1 2 3], [4 5 6], [7 8 9]] Output: 7 4 1 8 5 2 9 6 3 Input: mat[][] = [1 2], [3 4] Output: 3 1 4 2 Input: mat[][] = [[1]] Output: 1 Constraints: 1 ≀ mat.size() ≀ 1000...
geeksforgeeks
Medium
{ "class_name": "GFG", "created_at_timestamp": 1729172254, "func_sign": [ "static void rotate(int mat[][])" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass DriverClass {\n public static void main(String[] args) {\n Scanner ...
{ "class_name": null, "created_at_timestamp": 1729172254, "func_sign": [ "rotate(mat)" ], "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 matrix = []\n for i in range(N):\n arr...
eJztmM1uHUUUhFkgdmxZl+46QtP/3TwJEkEswAs2JgtHQoqCeAh4X+rrGcLYvnPjmCTCQCZj9XVXd59TdX5u+9dPf//8i0/mv68/8+CbV6cfr1+8vDl9pVN4fh0Wv4pKyiqqauoamr8NClEhKWSFolAVmkJXGIqejl4VFZNiViyKVbEpdsWh5OkUlLxrUspKRakqNaWuNJQ9nYNyVPapWbkoV+Wm3JWHiqdLUIkqScVWFZWq0lS6ylD1dA2qUTWpZlVbXVWbalcdap5uQS2qJbWsVtTsVVPrakPd0z2oR/WkntWLelW31119aHh6BI2o...
712,536
Insert Interval
Geek has an array ofnon-overlapping intervalsintervalswhereintervals[i] = [starti, endi]represent the start and the end of thei**thevent andintervalsis sorted in ascending order bystarti. He wants to add a new interval newEvent =[newStart, newEnd]where newStart and newEnd represent the start and end of this interval. E...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1666857631, "func_sign": [ "static ArrayList<int[]> insertInterval(int[][] intervals, int[] newInterval)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.math.*;\nimport java.util.*;\n\nclass GFG {\...
{ "class_name": "Solution", "created_at_timestamp": 1666733333, "func_sign": [ "insertInterval(self, intervals, newInterval)" ], "initial_code": "# Initial Template for Python 3\n\n# Position this line where user code will be pasted.\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(...
eJytlM1OhDAQxz0Yn2Pk5GHWdKa0gE9i0hIPysFL3QObmBiND6HvawfWGBM7wEYukAC//j/aeT//vLo4m67by/wQXqrHtD+M1Q1UFJOJyUFTIVTD8364H4eHu6fDeHwfgsOm72N6i6l6Rfj9q4uJgGNisDFZqGOqwQnOZyz4ItOgLzKtMDPEA2VlxEBOYGwUGpttODJAXOQRuh6DR3JFan00bmd0E1M78VkxTTlIDC1SWaxEOutUBTokLjJYpFlR1Yket2izW+eyFR4RUGZ3QLXC5cy1Ez27rTW3Bma5SrdWq9aAhAViW0g7DbUjhVUu...
701,313
Minimum indexed character
Given a stringstrand another stringpatt. Find the minimum index of the character in strthat is also present inpatt. Examples: Input: str = geeksforgeeks patt = set Output: 1 Explanation: e is the character which is present in given str "geeksforgeeks" and is also present in patt "set". Minimum index of e is 1. Input...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1619239298, "func_sign": [ "public static int minIndexChar(String str, String patt)" ], "initial_code": "import java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\n//Position this line where user code will be pasted.\n\nclass GFG {\n\tpublic static v...
{ "class_name": "Solution", "created_at_timestamp": 1619239298, "func_sign": [ "minIndexChar(self,Str, pat)" ], "initial_code": "import atexit\nimport io\nimport sys\n\n_INPUT_LINES = sys.stdin.read().splitlines()\ninput = iter(_INPUT_LINES).__next__\n_OUTPUT_BUFFER = io.StringIO()\nsys.stdout = _OUTPUT_B...
eJztV9tOg0AQ9cEP8BManiuh4P1LTFxjuBbaMqClFmo0foTGN7/V2aW21DJLKTaVxAnpbsMyZ+bM2cnu6+H759GBsOsPnNw8KQHEk0S56igGA5OyGb5jYMkMl/BHZuhE6XYUN41dO3Gdu2iSzLE1Bi8M9EsxHPfEoDx3O4XwdAZpNqMeAR5CFN8/jMMEfxmMk8kjAacLgLMymBMM0rId1+v7wWA4mrtEV1NEod8gfpZK02dgW+Yixvwz4Y8B91hCfgWXMyo5o8jifOidE5xKkkXLY8NXIrU0tyzDf2lGwJ8KII2CMy3Lth3HdT2v3/f9...
705,546
Satisfy the equation
Given an array A[ ] of N of integers, find the distinct index of values that satisfy A + B = C + D where A,B,C & D are integers values in the array.Note: As there may be multiple pairs satisfying the equation return lexicographically smallest order ofA, B, C and D and returnall as -1 if there are no pairs satisfying th...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int[] satisfyEqn(int[] A, 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 Buffer...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "satisfyEqn(self, A, N)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n A = list(map(int, input().split()))\n ...
eJytVMFOhDAQ9WD8jpeeV0NbWsAvMRHjQTl4wT2wiYnR+A/qxa91psXVXZlu6FIYSmnn9c3wpm+nn19nJ6FdvdPL9bN66NebQV1C6bbnW62guqd1dzd097ePm2GcPdf4udv+te3Vywq7zoacC26IXTaQJSAY2GyAco8JCC4bzP2CoeEGF0YuEWOgj1JA9Bzf9hIgAmlYAUIXgRUMmSUrIyF4soqsJmvG+MUNLG8hbcBh0wqDEpN9kraXJEK0Yw51/DXjkz/V5Pcns2EmZrziXIaxCWMPB48KNQhHDk+Tk0toVUz9YU0UW60nUzxDXFPq...
703,753
C++ Nega Bit
Given two integer numbers, F and S.In binary form of the numbers, for every i**thset bit in F, negatethe i **thbit inS. Examples: Input: F = 2 , S = 5 Output: 7 Explanation: 2 is represented as 10 in binary and 5 is represented as 101. Hence negating the 2nd bit of 5 from right, thus the new number becomes 7 i.e. 1...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int negaBit(int F , int 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": [ "negaBit(self, F , S)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n F, S = map(int, input().split())\n\n ob = Solution()\n ...
eJytVMtKxEAQ9KD/0eS8yPRrpuOXCEY8aA5e1j1kQRDFj9Cf8OYfOpnMKot2sopzSWCmi6rq6n4+fn0/OSrn/C3/XDw0t+vNdmjOoMFujYEYFPNfs4Kmv9/010N/c3W3HeobRerWT/n6cQX7pUpCZtCW49ZL0jTC/wgRVTkCMoZELgK2MQZzEDCIaVKoXxckOPUTe7ByfAomxq1HgVg0QlRhmvGRg0X1WFjK5TAhuRBtagOKx2I0EYEiobAvpFrtNzTBjIbxQZx30q8u924fs3RedhGTZQnpQBDsOqqq/oT31ZYyIUu9URenhuwzpGPY...
703,909
Modular Exponentiation for large numbers
Implement pow(x, n) % M.In other words, for a given value of x, n, and M, find (x**n) % M. Examples: Input: x = 3, n = 2, m = 4 Output: 1 Explanation: 3 **2 = 9. 9 % 4 = 1. Input: x = 2, n = 6, m = 10 Output: 4 Explanation: 2 **6 = 64. 64 % 10 = 4. Constraints: 1 ≀ x, n, M ≀ 10**9
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public long PowMod(long x, long n, long m)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG\n{\n public static void main(String[] args) throws IOExce...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "PowMod(self, x, n, m)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n x, n, m = input().split()\n x = int(x)\n n = int(n)\...
eJxrYJmqyMYABhFSQEZ0tVJmXkFpiZKVgpJhTJ6hgoECkFLSUVBKrShITS5JTYnPLy1BKKgDStbqKKDqAurBo8sAhy5D8nQZwABQuxE5liIZAGeS7GVLCDA2V0CwiDHOxMDMwMjC0ByHsUYkOs/cwtzQAGi3Gb4wpoYvjRD+pCjKSPIdVgMNcChGV0akOrRAp2KwA2lc/iUvNpBMNcQ0llxTMX2Py9O4fEtZdgR7CWe2hHoXzRYQyxChGkuxgBIm5Ac1HnfFKBDnMiMqOw1hFPakCzM3Bn/KJhRTsVP0AA90sq8=
713,193
Geeks And The String
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Examples: Input: aaabbaaccd Output: ad Explanation: Remove (aa)abbaaccd =>abbaaccd Remove a(b...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1671618299, "func_sign": [ "public static String removePair(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 = new BufferedRea...
{ "class_name": "Solution", "created_at_timestamp": 1671618299, "func_sign": [ "removePair(self,s)" ], "initial_code": "# Initial Template for Python 3\n\nimport atexit\nimport io\nimport sys\n\n# Contributed by : Nagendra Jha\n_INPUT_LINES = sys.stdin.read().splitlines()\ninput = iter(_INPUT_LINES).__nex...
eJxrYJm6lIUBDCLmARnR1UqZeQWlJUpWCkqGMXmJSjoKSqkVBanJJakp8fmlJVCpxJi8upg8pVodBTT1Sbg0JOHSgcsKXUOcdiTjtCQZp54k0u0BakrGZRUBXSCSPJ0pKampaWmk6yUnHCEQZ2BCIE4bUTxLwNO43AAxgwxNpOoBuxHoRBzaknAmaCzehDmBdO9CDMIfXwR8gMsDuBMGOR5IxB9h8HQKYkOzF2634fQR3DACKRFmQOwUPQBUao0V
703,341
LCS of three strings
Given 3 strings A, Band C, the task is to find the length of the longest sub-sequence that is common in all the three given strings. Examples: Input: A = "geeks" B = "geeksfor", C = "geeksforgeeks" Output: 5 Explanation: "geeks"is the longest common subsequence with length 5. Input: A = "abcd" B = "efgh" C = "ijkl"...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1731665657, "func_sign": [ "int LCSof3(String s1, String s2, String s3)" ], "initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n Buf...
{ "class_name": "Solution", "created_at_timestamp": 1731665657, "func_sign": [ "LCSof3(self,s1, s2, s3)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n\n for _ in range(t):\n # n1,n2,n3 = map(int,input().split())\n s1, s2, s3 = in...
eJzlV11OwzAM5oFX7mD1eUK0GyA4CRJFaGu7AWPZ2NqtLQJxCLgfb1yDNnHTNIvbMpj4c6fEjqPEX/yT7Gn35W1vh9PZa8ac31vXbBaF1ilYjsv6SDBAAg/JZT4SBEgwRLI6YAXxLPDCwL+cRiGud+CyR5eJ1nroQHWrVBIY2dIYlaRhKkkjVSKMsuutmt3NFyAbl03YNGfCaAkTVnCiy1XEJj2++pFpjy7HBWh1Jgw8PxiOrq5vYHxb7AbRchUnaa7LZyifp3yZDBVldSJvAVm/HFKkvG/hPMcmkMSJ+kGtqEAVQMUxQoE003v+cJQr...
704,006
High Effort vs Low Effort
You are given n days and for each day (di) you canselect one of the following options: Examples: Input: n = 3 hi[] = {2,8,1} li[] = {1,2,1} Output: 9 Explanation: Options on 1st day: hi[0]=2, li[0]=1 or no-task Select no-task. Options on 2nd day: hi[1]=8, li[2]=1 or no-task Select high-effort task as no-task was sel...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int maxAmt(int n , int hi[] , int li[])" ], "initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*;\nclass GfG\n{\n public static void main(String args[])\n {\n Scanner sc = new ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "maxAmt(self, n, hi, li)" ], "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 hi = list(map(int, input().strip().spl...
eJy9lc1OwzAMgDlw4DGsnCdkJ02a7kmQKOIAPXAJO3QSEgLtIcb74iRUAjXONtStqfuzxfZnJ3Z311/rm6t03Bl+uH9XL2GzHdUaFPWBMAoQFC59sDAbagVqeNsMT+Pw/Pi6HX9MWduHzz6ojxUUHJSsQ/yn47tnaVkciwWSHKDkwEYznk04Vm/AgGZDmu8Nvztoo/9frzz1z3TBn/eCP41RgBidyRmcuRm7ATJA7DpFNwNKSThmCDhEVOGZBxgzTInHJDabONvE3MH/YhDQdGOkpcmnFFJFCxHzVdJNE8r5SKnO2nI6EcV8Tqp534oI...
707,042
IPL 2021 - Match Day 2
Due to the rise of covid-19 cases in India, this year BCCI decided to organize knock-out matches in IPL rather than a league. Examples: Input: N = 9, K = 3 arr[] = 1 2 3 1 4 5 2 3 6 Output: 3 3 4 5 5 5 6 Explanation: 1st contiguous subarray = {1 2 3} Max = 3 2nd contiguous subarray = {2 3 1} Max = 3 3rd contiguous...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1618213696, "func_sign": [ "static ArrayList<Integer> max_of_subarrays(int arr[], int n, int k)" ], "initial_code": "import java.util.*;\nimport java.io.*;\nimport java.lang.*;\n\nclass Main {\n public static void main(String args[]) {\n // tak...
{ "class_name": "Solution", "created_at_timestamp": 1618213696, "func_sign": [ "max_of_subarrays(self,arr,n,k)" ], "initial_code": "# Initial Template for Python 3\n\nimport atexit\nimport io\nimport sys\nfrom collections import deque\n\n# Contributed by : Nagendra Jha\n\n_INPUT_LINES = sys.stdin.read().s...
eJzdVTtPxDAMZmDhX1idTygv98EvQaKIAW5gKTfcSUgIxMbGBP+XL8616KDu40AIXdLElePYzmfHeT5+fz05knb+gp+Lh+y2WW3W2Rlltm4sE9eNp7Zz1/O2ZwvKlver5fV6eXN1t1lvN/fKUt081U32uKBdM86QNbBmqKKSCggyBZhzZNEd/oKoKbBaQVSxubP/U1qzyoYci1XY94aCIbByQ4WhEqqiU0JKYeWyHERUHCag45g8fMUpYZGpYCqZKpkL4bCsepGMaEYaZAUi1mDEBXAsWBY8B54Dz4HnclaPmrwbGxX3fBPMapghHhEx...
703,144
K-Pangrams
Given a string str and an integer k, return true if the string can be changed into a pangram after at most k operations, else return false. Examples: Input: str = "the quick brown fox jumps over the lazy dog", k = 0 Output: true Explanation: the sentence contains all 26 characters and is already a pangram. Input: str...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "boolean kPangram(String str, int k)" ], "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 Scanner sc ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "kPangram(self,string, k)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n\n for tcs in range(T):\n string = input()\n K = int(input())\n ob = So...
eJy9k81Og0AUhV0Yn+OEdWOsSTc+iYljDDADTKHD3wwFjMY3cKM+r3caf2pbME6J34oNJ3e+e+7T6evb2cmG62f6uLn3pCqM9q7gzZkKQi6iOJHLNFupvCirWptm3XY9U5cLbwZPtIUIteB3udEfv0V+VgumHpnyHmb4mdd37boxuq7KIlerLF3KJI4EDwOfqYuBPF2ZoTgfAUJwCESIkUBiiRQZVkzNh+LGxitHYGrhMGG5FpXujMwLv+ZkkkT2bdgEikYcEjj24K+F4Hsj+FzJ3CGQQEAgJMAJCAIRgZhAQkBKcku4WdgqDuwTsF0q...
703,293
Maximum number of zeroes
Given an array arr[] of integers, the task is to find the number that has the maximum number of zeroes. If there are no zeroes then print -1. Examples: Input: arr[] = [10, 20, 3000, 9999, 200] Output: 3000 Explanation: 3000 contains 3 zero's in it. Input: arr[] = [1, 2, 3, 4] Output: -1 Explanation: No zero is pres...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public String maxZero(ArrayList<String> arr)" ], "initial_code": "import java.util.ArrayList;\nimport java.util.Scanner;\n\n//Position this line where user code will be pasted.\npublic class Main {\n public static void main...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "maxZero(self, arr)" ], "initial_code": "import sys\n\ninput = sys.stdin.read\ndata = input().splitlines()\n\nt = int(data[0])\nsolution = Solution()\n\nfor i in range(1, t + 1):\n arr = data[i].split()\n print(solution.m...
eJytVMEKwjAM9SB+R+hZJV073fwSwYkH3UEP08MEQRQ/Qv/XWOusYymurJAQuiwv6Uty6z92g5458zUZi7PYFodjKWYgZFZIiECBzgoxBJGfDvm6zDer/bG0LiPyudLXyxBqPyJECArRVSkdukY23MuLCxgpHU+mSQppMp3EWkUSqjusTKxM9OC4Lo1o7QvmwdiKKFU08lZW468p+SIqbw6A2JOgJGg+CFtPHMI5vlg3ZIMmiX0UePL+VOUvvKNGMQ/1T7cknoSJL8rKZbFzMh2MOrfBmN94TAPVgEJmmm+XZqLcrRM23TyikdaT3dFc...
703,436
Find the smallest and second smallest element
Given an array, arr of integers, your task is to return the smallest and second smallest element in the array. If the smallest and second smallest do not exist, return -1. Examples: Input: arr[] = [2, 4, 3, 5, 6] Output: 2 3 Explanation: 2 and 3 are respectively the smallest and second smallest elements in the array...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1618922067, "func_sign": [ "public int[] minAnd2ndMin(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 IOExceptio...
{ "class_name": "Solution", "created_at_timestamp": 1618922067, "func_sign": [ "minAnd2ndMin(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 obj = Solution()\n pr...
eJytVMFugzAM3WHSfsPKuZ0wJYX1Syot0w4bh17SHkCaNG3aR6z/W4MJawdOoGmQgkPCi/3s55/7Y/1w146tJeP5U+3soa7UBhQai0kzoHs9NQMuvqkFqPLjUL5V5fvrvq66X89PGvttrPpawCX0EAzbCwpepB7kgj3xAg9mAW+JAozzDAaGgIT+eMc4PIuXF7kn6pyPS/AOJnXGyhmZM7ToeSqipoSTgYY15EC8ExQg3UW3ED4hX4MpUxvJsYaR58rEBxLVzut21mEtaD4eYkRz8hBnpm8VSl8vC07j/Jx5OZkaQkbbWaDS8a8RCL4k...
713,994
Frogs and Jumps
Nfrogs are positioned at one end of the pond. All frogs want to reach the other end of the pond as soon as possible. The pond has someleaves arranged in a straight line. Each frog has the strength to jump exactlyKleaves. For example, a frog having strength 2 will visit the leaves 2, 4, 6, ... etc. while crossing the po...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1676003114, "func_sign": [ "public int unvisitedLeaves(int N, int leaves, int frogs[])" ], "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...
{ "class_name": "Solution", "created_at_timestamp": 1676003114, "func_sign": [ "unvisitedLeaves(self, N, leaves, frogs)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n while T > 0:\n N, leaves = [int(i) for i in input().split()]\n ...
eJytVEtOAzEMZYE4x9OsKxQ7cZLhJEgMYgFdsBlYtBISAnEIOAU7TogdWolWuNChs4om8fv4xXk5fvs4OWrf+bsuLh672/F+uejO0NEwCjgMI4ERkSDdDN384X5+vZjfXN0tF6uDeuR5GLunGTarE0iG0WozilObnNoMCkYdVAFiQAqQgBwcmN7TQFZnRnRBZgcshhfFIJPorqfMg4wmTTdZBcWojQmuqp58WV8gpmlbEETUKbLX71pcWFaHDRaCAiKQqtVFD47gHpEQCxLtmSSZxOZZw9yNjKQdcdOm4jCw5WQMCRVqg3LLKoErorLm...
704,178
Number Formation
Given three integers x, y, and z, the task is to find the sum of all the numbers formed by having 4 at most x times, having 5 at most y times, and having 6 at most z times as a digit. Examples: Input: X = 1, Y = 1, Z = 1 Output: 3675 Explanation: 4 + 5 + 6 + 45 + 54 + 56 + 65 + 46 + 64 + 456 + 465 + 546 + 564 + 64...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1616485809, "func_sign": [ "public int getSum(int X, int Y, int Z)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nclass GfG {\n public static void main(String args[]) {\n Scanner sc = new Scanner(Sy...
{ "class_name": "Solution", "created_at_timestamp": 1616485809, "func_sign": [ "getSum(self, X, Y, Z)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n X, Y, Z = map(int, input().split())\n ob = Solution()\n ...
eJydVMFKxDAQ9aD/EXJeZDKZmSR+yYKRPWgPXuIeurAgih+h/2uaVlgwSaslhRbmvXnz8pKP66/DzVV59vv8cf+qn9PxNOo7pU1MAqosvVN6OB+Hx3F4OrycxqWCxRhybGN6j0m/7dQFGmOyoMqKiYMqq8ETyJC3AbEQETIRMXKNNvcyoHCmJVA8yVsV6j2DyYxUKFk8IXmwy193iEI8d+g1IIbME+YJBIwTH9jXOLOtRb6iFpkBK94BQwO+4mbXP/Mz0aZBauCeC4bAWcLQABcPm2AnQNm0lmwppmHTNLFW0ENVeNm/6W1Kb9m0ptox...
703,636
Magical String[Duplicate Problem]
You are given a string S, convert it into a magical string. A string can be made into a magical string if the alphabets are swapped in the given manner: a->z or z->a, b->y or y->b, and so on. Examples: Input: S = varun Output: ezifm Explanation: Magical string of "varun" will be "ezifm" since v->e , a->z , r->i ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static String magicalString(String S)" ], "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 Buffe...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "magicalString(ob,S)" ], "initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n S = str(input())\n\n ob = Solution()\n print(ob.magicalS...
eJy1VEuO1DAUZIHENVpZj5CAWXESJIKQYzu2E/vZ8S+O0YzmEHBBdtwCdw+oGRGnuxk6K0vxq1ev/KoeXn778erF4fvwvRw+fmkEmOCb97vmXQuow4T2jIthlAq0mazzIc5pyS3kJc0xeGcno0HJcRCc9ZTgDrWgBCGSNje7hiZDsafksw7+F+5W4f12z/Ib7DzreDg2dze7P/i+LX0RExjJFpy3ApinzldIQPY2ZX3A4UxY5VnkbA32TQtYKyNpEn6poCUJo47Ysm4N4bYMhboOY0Io7fsWGONciGEYR1m4KgWgtTHTZG1h7rwPIcZ5...
703,143
Remove Spaces
Given a string, remove spaces from it. Examples: Input: S = "geeks for geeks" Output: geeksforgeeks Explanation: All the spaces have been removed. Input: S = " g f g" Output: gfg Explanation: All the spaces including the leading ones have been removed.
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "String modify(String S)" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])throws IOException\n {\n BufferedReader br...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "modify(self, s)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n\n for _ in range(t):\n s = input().strip()\n ob = Solution()\n ans = ob.modify(...
eJylU8EKwjAM9bAPCTkPYVe/RLAiaZuBl7pDB4IofoQ7ePNTbaseHKRuNYdQSF5fXl57rYZHtUixvofD5oR71/UeV4CNckBYA/KxY+PZ7g69f9dIuYtyeK5hBAABIPSTNpZbiSQVJSYCDQYsMLQSaf6CEKFBhsojR+hsXOKLScdUeAeJGBkRCU0B1zwnv+UV6uMprnLW1hJLx7NPcbnJLrxg3yqE7G+syp/u33elyWkn7e1VzMnN6s0Kph+KP5K3t+UTqfZ0FA==
702,732
Sum of Series
Write a program to find the sum of the given series 1+2+3+ . . . . . . (n terms) Examples: Input: n = 1 Output: 1 Explanation: For n = 1, the sum will be 1. Input: n = 5 Output: 15 Explanation: For n = 5, sum will be 15. 1 + 2 + 3 + 4 + 5 = 15. Constraints: 1 <= n <= 10**9
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public static long seriesSum(int n)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(ne...
{ "class_name": "Solution", "created_at_timestamp": 1663597771, "func_sign": [ "seriesSum(self, n : int) -> int" ], "initial_code": "if __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n n = int(input())\n obj = Solution()\n res = obj.seriesSum(n)\n print(r...
eJzNVc1OwzAM5sCBx5h6npBjx/nhSZAo4gA7cCk7bBISAvEQ8ELceCucpM06aLZ2aIhKda3I+b7Y/py+nr5/np3E5/JDnKun6r5ZrlfVxayiulEAUDcMEL8Kuqeaz6rF43Jxu1rc3TysV+0OCeQQ+CKxGHZFkxa425uduFw9z2c9Tqwb732mKvBo73kLlouAWrACXIRMuAVQlfC4heWMz8PIEqjiC9G0tvsUWbCtjyLk1kO2DNkHm2sYi2i5kJoa15ERVaceUq9TE/C5j556n9s/TQGpYUkHfSnsaxxFq+MmnkqKHY0wj0p5o+scvzln...
702,822
Pair Sum Closest to 0
Given an integer arrayofNelements. You need to find the maximum sum of two elements such that sum is closest to zero. Examples: Input: N = 3 arr[] = {-8 -66 -60} Output: -68 Explanation: Sum of two elements closest to zero is -68 using numbers -60 and -8. Input: N = 6 arr[] = {-21 -67 -37 -18 4 -65} Output: -14 Ex...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1618833982, "func_sign": [ "public static int closestToZero(int arr[], 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...
{ "class_name": "Solution", "created_at_timestamp": 1618833982, "func_sign": [ "closestToZero(self,arr, n)" ], "initial_code": "# Initial Template for Python 3\n\nt = int(input())\nfor tc in range(t):\n n = int(input())\n arr = list(map(int, input().split()))\n ob = Solution()\n print(ob.close...
eJytk0FOxDAMRVnAPb6ynqA6bdoMJ0GiiAV0wabMoiMhIRCHgNuw42I4qUdkOi1qWqKR3Eie7+dv5/388/viLJzrL/64eVGP7W7fqSsoqlvK6lZvw4GmLBxoK5GQgSA3yTokGbWBap53zX3XPNw97TsRZcG3ulWvGxxXclyIWJPrOOgKukSOAnZCRtOEDpkgJIS/6EzNgs7zeWKUEbUEOsAnopMdK+nkXkksj83LpBhMH/I+FH2IPXUDaxPpqhhudHLLdK0MzDAtiH9LBISgkAZN7rkmdKYm7k4aJAyEbeQqrbOzjB6EjMewld7RNYOJ...
700,536
Euler Circuit in an Undirected Graph
Eulerian Pathis a path in a graph that visits every edge exactly once. Eulerian Circuit is an Eulerian Path that starts and ends on the same vertex. Given the number of vertices v and adjacency list adj denoting the graph. Find that there exists the Euler circuit or not. Return 1 if there exist alteast one eulerian cir...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public boolean isEularCircuitExist(int v, ArrayList<ArrayList<Integer>> adj)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass GFG {\n public static vo...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "isEularCircuitExist(self, v, adj)" ], "initial_code": "# Initial Template for python3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n V, E = map(int, input().split())\n adj = [[] for...
eJylVMsOgjAQ5KDxNzY9E9MHEPVLTMR4UA5ekAMkJsbEj9D/tbsQ3sQu9sCj7MxOO1Nei89q6dHYe/bh8BDXNCtysQOh4lSBjFPhg0juWXLOk8vpVuTNZ/H0oQvQYC8S1ARGjmM0YdhAA6YCKqTQIDlSB2hW7wDCLtogo8Q5zeEJIRrhCbABkRke2aa3IUTRZlT4qiHg0EawndIYYtNy1fO4lcTBj1kdGU5mUOhEcb/SvfRHGOwcKxBmXiRJsLviZttrf83fBg+tIlWVXzHdS51t9+qj72qN1eG8zvKQO/8jju/1F5Pdejc=
701,339
Evaluation of Postfix Expression
Given string Srepresenting apostfix expression, the task is to evaluate the expression and find the final value. Operators will only include the basic arithmetic operators like *, /, + and -. Examples: Input: S = "231*+9-" Output: -4 Explanation: After solving the given expression, we have -4 as result. Input: S = ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1619436835, "func_sign": [ "public static int evaluatePostFix(String S)" ], "initial_code": "import java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\nclass GFG {\n \n\tpublic static void main (String[] args) throws IOException {\n\t\tBufferedRea...
{ "class_name": "Solution", "created_at_timestamp": 1619436835, "func_sign": [ "evaluatePostfix(self, S)" ], "initial_code": "# Initial Template for Python 3\n\nimport atexit\nimport io\nimport sys\n\n# This code is contributed by Nikhil Kumar Singh(nickzuck_007)\n\n_INPUT_LINES = sys.stdin.read().splitli...
eJytVEFOxDAM5IAEN75Q5ZhsCLGTtOUlSARxgB64hD10JSQE4hHwX0Kzuy1q3Q1se2nTyGPPeOyP06+Ls5PuuTmPH7ev7CmsNy27Lhj6AKi5qKUPGlDwKn7UlbEguHSKrQrWvKybh7Z5vH/etNsoaXx490FieqUTe1sVA2Ttg0MDSvBSEjCAU4HggzUcQShXSa5FrAdNPJSCA4Ukyw5JawKwMtyiku4HrFQmsgRBQGGCkkCQKp01UZuK1MYRgbVREPMTYZSGGlRkzy3J3FLpdD1T5RURhTVdoqYkAS2Rk2GTTaZ9N+Sc78HJxifRD1h8...
704,961
Face off Tournament
Ram and Rohan are participating in a tournament where they must compete against contenders whose strengths are given in an array arr[]. Ram's strength is m, and Rohan's strength is n. They take turns competing against the contenders, with Ram always going first. A contender is defeated if their strength is an exact mul...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public String winner(int[] arr, int m, int n)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\...
{ "class_name": null, "created_at_timestamp": 1615292571, "func_sign": [ "winner(arr, m, n)" ], "initial_code": "def main():\n t = int(input())\n for _ in range(t):\n arr = list(map(int, input().split()))\n m, n = map(int, input().split())\n print(winner(arr, m, n))\n pri...
eJy1VEtKRDEQdCF4jeKtRdJJ5+fSI7gSfCKiA7rwjYsRBFE8hB7FnYez05l5+OHJxNFmmAozSSrpqtTT9svbzpbW0asMju+7q+HmdtHto6N+IKMFX8EqIlag+pt+O53QD378o9tFN7u7mZ0vZhen89vFctPDs+t+eOyH7mEXn7lyTpbZeQeyjn2IKSOnGDw7S1ieRLeHheuHCKIJkoP54nKSRXgcCsSs4CuETxx+NRpX2KkLzS/PhgkyMpalQZzAJgckyhYUXGI4G0NC8N4FkCMTbT+Mc5pbJ913BsGYIN2xRj6wLNwGnITdIAfZW+5i...
703,770
Find the Highest number
Given an integer array a[] of size n, find the highest element of the array. The array will either be strictly increasing or strictly increasing and then strictly decreasing. Examples: Input: 11 1 2 3 4 5 6 5 4 3 2 1 Output: 6 Explanation: Highest element of array a[] is 6. Input: 5 1 2 3 4 5 Output: 5 Explanation...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1619347091, "func_sign": [ "public int findPeakElement(List<Integer> a)" ], "initial_code": "import java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n BufferedRead...
{ "class_name": "Solution", "created_at_timestamp": 1619347091, "func_sign": [ "findPeakElement(self, a)" ], "initial_code": "if __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n = int(input())\n a = list(map(int, input().split()))\n ob = Solution()\n an...
eJylVNtqFVEM9UH8jsU8F9m57CS7XyI44oOeBxHGIqcgiMWP0P81ezjQFkzbwxmGYZjZWclaK8nv13+/v3m1X+++5sv7n8uX7eb2uFxjoXWzdSNQ2y8wBIq+XGE5/Lg5fDoePn/8dns8ne7rdrduy68rPIagNjFOsTA4AiMxC5h5/L84vONIYviMz7IE1EEOGuAGCpCBFMSJnkksE3KRhasssW73RU4EKhBGASB5g+rElUr9nt3k1icladCGns8OyS99Eiv1ryj59OARXAKdjcK7i2eyyu9cKlhK0YqO2YXh3Xfdrbfd/Tg1AGcMgwWs...
703,913
Factorial
Given a positive integer,N. Find the factorial of N. Examples: Input: N = 5 Output: 120 Explanation: 5*4*3*2*1 = 120 Input: N = 4 Output: 24 Explanation: 4*3*2*1 = 24 Constraints: 0 <= N <= 18
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1619259404, "func_sign": [ "static long factorial(int N)" ], "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 BufferedReader(ne...
{ "class_name": "Solution", "created_at_timestamp": 1619259404, "func_sign": [ "factorial(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.factorial...
eJytU7lOw0AQpUD0dJSR6wjNffAlSARRQAoaQxEkJATiI+B/GYeCpJhAUNbFru15x87xfvx5dnK0Xpendbh6Ge7Hx6fVcDEbcDHCMJ8Ny+fH5e1qeXfz8LT6+fW2GIfX+Ww7HqMBmACxs4M6BQB0+D31uJPr+L0BsKqFS3lL6+1Zg3ZqL9RlkI0iWiFqUNTE506Vzpt22WZwc2HbVakS3bda9I2boNBWQhESUggdvXaB3sMG32HZDkGHm5SLdbon4rYfMtH6hkDtgOrIHJxqIhoqmiAeyRSmZAhaJhkjVVk9DBDJBINUgl2DGT2DEklC...
706,447
Shortest Unique prefix for every word
Given an array of words, find all shortest unique prefixes to represent each word in the given array. Assume that no word is prefix of another. Examples: Input: N = 4 arr[] = {"zebra", "dog", "duck", "dove"} Output: z dog du dov Explanation: z => zebra dog => dog duck => du dove => dov Input: N = 3 arr[] = {"ge...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static String[] findPrefixes(String[] arr, 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 ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "findPrefixes(self, arr, N)" ], "initial_code": "# Initial Template for Python 3\n\nimport sys\nsys.setrecursionlimit(10**6)\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\...
eJzFV8ty0zAUZcGWP2BxJ2w7DB3efAkzmGEc69pWI0uJJNMEBoaPgP9Fjys7TavGadLWi+hIkc45lq505T9P/7149iQ8n5878OXnjMtlb2efYHZeyLeFLMcHYjEfcTVAxgJEeuq6LuTsDGa4XmJlkX1TvSXeHTZiiiyAUMjfbuivM7hq5fyV8zKvXI+6aYFfLAR0Ui1hpY2F/vvlGjY/HFnFsIam5RewEJ3Me3BCHDpYQQ8bqKCBRU74QyFbFEJdKi0YBGh6ScCWOqJOKQlYatuGtoC22noCgSTrKuokjSRBAomduBMx8ebcvyvkUmPN...
702,675
Count minimum right flips to set all values in an array
A wire connects light bulbs. Each bulb has a switch associated with it, however, due to faulty wiring, a switch also changes the state of all the bulbs to the right of the current bulb. Given the initial state of all bulbs, find the minimum number of switches you have to press to turn on all the bulbs. "0 represents th...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public static int countFlips(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": [ "countFlips(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 ...
eJxrYJnqyMoABhFWQEZ0tVJmXkFpiZKVgpJhTB4QKekoKKVWFKQml6SmxOeXlkAlDWLy6oCStToKqDoMcOowxKHDUAEKSbcLqAsN47YdlyEYRijg9oIlTodgQDKCAd0M3J4xImAG6TrBuhQMCeg2IRCGMNKAoEkWuEzCFRKkpg14qsKVTkhObWCnkawH7n4ojRbQRPgQV5SR5wGYa6gQwFjinIxINzDAoRqrlWDj8cUEzqyB8DyBcCAveGKn6AEALneC/Q==
705,573
Closest Triplet
Given three sorted arrays A[] of size P, B[] of size Q and C[] of size R.Find a number X such that when 3 elements i, j and k are chosen from A, B and C respectively,thenX=max(abs(A[i] – B[j]), abs(B[j] – C[k]), abs(C[k] – A[i])) is minimized. Here abs() indicates absolute value. Examples: Input: P=3 A[] = {1, 4, 10} Q...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "int findClosest(int P, int Q, int R, 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 IOEx...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "findClosest(self, P, Q, R, 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 P = int(input())\n A = list(ma...
eJztmMGOJDUMhgeJp4BL1OcVimMnqeJJkFjEAebAZdjDroSEQDwEvCwn/t/5CzVoa2HEsLDQI8We6bK/OLHj1PQP7//03od3+fPJzx/c3X367eWrhxevXl4+Lhd7/mAVo7QSZSs2ircyoljbSuujdGvLwsvAh6VFia3s+H1vxbcoc8Cr+1hWvVgtrZaoZaugVeAqeJXASmK9PCuX+29e3H/x8v7Lz79+9VKBYJrvnz9cvntWfhtdJ7gSCuEUQdEh1sPOhxROERS9Hw8bH1I4RVB0iJMY0u21UWzcIi+9zLIXs2KORefH3LfBneMSi2Hn...
702,919
Maximum Product Subarray
Given an array arr[] that contains positive and negative integers (may contain 0 as well). Find the maximum product that we can get in a subarray of arr. Examples: Input: arr[] = [6, -3, -10, 0, 2] Output: 180 Explanation: The subarray [6, -3, -10] gives max product as 180. Input: arr[] = [2, 3, 4, 5, -1, 0] Output...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1731059423, "func_sign": [ "int maxProduct(int[] arr)" ], "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 BufferedReader(new ...
{ "class_name": "Solution", "created_at_timestamp": 1731059423, "func_sign": [ "maxProduct(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()\...
eJylUkFOwzAQ5ABP4MZh5XMXrTeOG3gJEkUcIAcuoYdUQkJIPKL9L2s3rSjxWJWwE9mH3fHM7Hxf7m6uLvJ6uLbL46d7G9ab0d2T86vBixB7mh1uQa7/WPcvY//6/L4ZDx2S12pwXws6RbI+VuKGOBC3qF9Br72rQi0JNfY8aY1ACSEB2F866lLKcEL7baKmK0BBVmQnkhEUiZfU0R0AaKJ2XVmSgTSTpxmJIy0RimgogrQJIJlqU9GEIJCJDwHMJhmwZxPyiCr5QPOl43fYEKISLm86JkqVkGmcQcDav3UwLvWMoKHXogOEiv+33WbO...
703,592
Program to print reciprocal of letters
Given a string S, we need to find reciprocal of it. The reciprocal of the letter is found by finding the difference between the position of the letter and the first letter β€˜A’. Then decreasing the same number of steps from the last letter β€˜Z’. The character that we reach after above steps is reciprocal.Reciprocal of Z ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static String reciprocalString(String S)" ], "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 Bu...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "reciprocalString(self, S)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n S = input()\n ob = Solution()\n print(ob.recipro...
eJydk9tugjAYx3exvUfl2izxdncqnhVFVJB1WRBQ0dKichKzZQ+xve9AvDHmqweumvDr1/+h/Xn+016ejp8mp4v3g+BQL/CFNySUMDWEIhLs2LNN37Y+WeCffiWYfmMqfBXROZ8AvAHwZYDXAV4H+DLAuwBPAb4H8BLAI4BHAG/MTMueL5bOak1cyrzNducHYRTvoeCSfRyFgb/bbjxGXbJeOcvF3LbMGZhopSrW6o1mq93p9qT+QB4qo/FE1aZQdPpUUyfjkTKUB32p1+20W81GvSZWK1CmTZsQhlS2JVYBmKmEjBEkEodFhVt13qWR...
706,073
Help Classmates
Professor X wants his students to help each other in the chemistry lab. He suggests that every student should help out a classmate who scored less marks than him in chemistry and whose roll number appears after him. But the students are lazy and they don't want to search too far. They each pick the first roll number af...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public static int[] help_classmate(int arr[], int n)" ], "initial_code": "//Initial Template for Java\nimport java.util.*; \nimport java.io.*; \n\nclass GFG \n{ \n\tpublic static void main (String[] args) { \n\t\tScanner sc = ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "help_classmate(self, arr, n)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n for _ in range(int(input())):\n n = int(input())\n arr = [int(x) for x in input().split()]\n ...
eJztV81u00AQ5sAL8AaffG6Rd2d/OfEYSARxgBy4hB5SCQmBeAh4X76ZtdsQaqdWozaRmqw3tmZ3duab+SbjXy//vH31wj7vKm/ef+++bK6ut90bdG61cb1e8D2kR4SPcBHCWZ9C312gW3+7Wn/arj9//Hq9HTZG6PfS6WKutMV84lhtfq423Y8L7B0TeXEdT0KtENSCgJq5ryYk1IiMGlAmDqRmr+pFp6CTHZh0yjqVmcM9faQz3OyhRqByeeZmtT7ACRwFTkFwFa7AZbg0YcmohseNahSHHTX6eKtmxq6o2Ju6gGiaSrOu6Rl0NjNN...
703,049
Reverse sub array
Given an array arr, you need to reverse a subarray of that array. The range of this subarray is given by indices L and R (1-based indexing). Examples: Input: arr[] = [1, 2, 3, 4, 5, 6, 7] and L = 2 and R = 4 Output: [1, 4, 3, 2, 5, 6, 7] Explanation: After reversing the elements in range 2 to 4 (2, 3, 4), modified ar...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public static ArrayList<Integer> reverseSubArray(ArrayList<Integer> arr, int l,\n int r)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "reverseSubArray(self,arr,l,r)" ], "initial_code": "if __name__ == \"__main__\":\n t = int(input())\n while t > 0:\n l = int(input())\n r = int(input())\n arr = list(map(int, input().split()))\n ...
eJytlN1Kw0AQhb0Qn+Ow10Vmf5P6JIIRQc1Fb9ZepCCI4kPo+zo7pMQUJj/aMg2FnTMz/c5kPy+/d1cX8rl95B93b2aX94fO3MDYJpeg8sUWNSokRAR4OFizgWlf9+1T1z4/vBy6o4jPPOdEzq1Ys0Up8NFk877BuLhvcuSA5XQWKQXLeWkYlCrHKUkbiLT+HI6fcIqS/6SidDK8nZhaZtb7VhxrYSrVmEsShxzBEwIhEhKhItRsm46lFyQRhEGg9IkSTJN1RVg0RTrB/TRT58E0ZcGUWrJIuhdlLgvLHD1sgOWVSdpUVo6DpLIgraNa...
703,095
Equal 0, 1 and 2
Given a string str of length N which consists of only 0, 1 or 2s, count the number of substring which have equal number of 0s, 1s and 2s. Examples: Input: str = β€œ0102010” Output: 2 Explanation: Substring str[2, 4] = β€œ102” and substring str[4, 6] = β€œ201” has equal number of 0, 1 and 2 Input: str = β€œ11100022” Output: ...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "long getSubstringWithEqual012(String str)" ], "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": [ "getSubstringWithEqual012(self, Str)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n\n for _ in range(t):\n Str = input()\n\n solObj = Solution()\n ...
eJylksEKwjAMhj3sQUbPQ5IcfRLBigftwUvcoUNBHD6Ee1/TdiA7hJHa9jBYvv7J//fdTGOzyWt/l4/D0125H6LbtQ49g+taFx59OMdwOd2GOP8Cz6Nn9+raZT0a68lYD6gRqBJpW9sCkmPvrRytQ9JMQyTRA81sdTSAgho5IYSz6yVPBMz+mNk054qungZXxCFU0VRJrVfv1QejjpfEZBEXn/BnVFULUJ9tyagupAzTP/DS+PkqWrvr+Nl+AbQSX98=
702,767
Find Maximum Sum Strictly Increasing Subarray
Given an array of positive integers. Find the maximum sum of strictly increasing subarrays. Examples: Input: arr[] = {1, 2, 3, 2, 5, 1, 7} Output: 8 Explanation : Some Strictly increasing subarrays are - {1, 2, 3} sum = 6, {2, 5} sum = 7, {1, 7} sum = 8, maximum sum = 8 Input: arr[] = {1, 2, 2, 4} Output: 6 Constr...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1617813667, "func_sign": [ "static int maxsum_SIS(int arr[], int n)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\nclass GFG\n{\n\tpublic static void main(String[] args) throws IOExcepti...
{ "class_name": "Solution", "created_at_timestamp": 1617813667, "func_sign": [ "maxsum_SIS(self, arr, n)" ], "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().strip().split()]\n ...
eJzNVbtOA0EMpKCgpqOzro7QPuy7W74EiSAKSEETUlwkJATiI+B/Ge89conikIhEItJqH/aOZ8f25fP8++riLP9uL7G4eyue54tlU9xQ4adz7zAoUCQmoRKDsQ7FhIrZ62L22MyeHl6WTXch4MbHdF68T2gDRhSKeiQg0Bi1otpAjKWBGEBMr7YwPZhfA+52BrRy2g6tZAEh4JXIewLzRDV2mameuRxj5YA4IIH4YgRLljJRBXYOEZLiOo3mAglOYh5ggn10qhmDQZ2jq4VWJEcm36nrLEUBv0NT1WyVGL+RpmoQwELnHRUgYwHXdc11...
705,739
Word Wrap
Given an array nums[] of size n, wherenums[i]denotes the number of characters in one word.Let Kbe thelimit on the number of characters that can be put in one line (line width). Put line breaks in the given sequence such that the lines are printed neatly. Assume that the length of each word is smaller than the line widt...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int solveWordWrap(int[] nums, int k)" ], "initial_code": "import java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG\n{\n public static void main(String[] args) throws IOException\n {\n Buffered...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "solveWordWrap(self, nums, k)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n = int(input())\n nums = list(map(int, input().spli...
eJztVsFOwzAM5cCZb7BynlDi1E3LlyBRxAF64FJ26BASmsRHwP/iuGWgNdnWtRPV1EXZEq9+SfOeHX9cfq2vLuRz+8qDu3f1XC1XtboBZYrKaO7QaUVFagGqfFuWj3X59PCyqlsffl6tF7CFQh4JMsjBAYGFBFJAHmU8z3lmiwp1BDFzIUjkhSwjpOztkQx/N/iJWJEt5JEB/foRbJOEwXm/juEaeCvbJNl0zuO0nfnlkX8dWwhy3k/sFWwaWsXK2SIc2eMcmCRIgub1SPZ6Np1fKHbmCQapJS1SRA1WQyIDnrJ+mEtWJsE//CncxKTj...
704,728
Prime Pair with Target Sum
Given a number n, find out if n can be expressed as a+b, where both a and b are prime numbers. If such a pair exists, return the values of a and b, otherwise return [-1,-1] as an array of size 2.Note: If [a, b] is one solution with a <= b, and [c, d] is another solution with c <= d, and a < c then [a, b] is considered ...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public static ArrayList<Integer> getPrimes(int n)" ], "initial_code": "import java.io.*;\nimport java.util.*;\nimport java.util.ArrayList;\n\nclass IntArray {\n public static int[] input(BufferedReader br, int n) throws IOE...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "getPrimes(self, n : int) -> List[int]" ], "initial_code": "class IntArray:\n\n def __init__(self) -> None:\n pass\n\n def Input(self, n):\n arr = [int(i) for i in input().strip().split()] # array input\n ...
eJytkkEKwjAQRV30IEPWVTKJJY4nEay40C7cxC5aEETxEHoad57MJHWjMKWMHbIIhDeT/+ffsscrm6RaPcNlfVYHX7eNWoLC0huVg6pOdbVrqv322DafpylCOKW/ll5dcviG5gxkwHCIY5GCQ8yCYQowloOIuEm9ilBrknAUamGFE2MxKDroWrPmiL6L3DwLjpfY2SrylchKDSJNLgqN3/bC9QSTMYYvRJbjDcRNUJ+AZLd8yynK/KoHpORHySid9Dit/u2VUo6DvN3cZ2/qFmwd
704,949
Least Prime Factor
Given a number N, find the least prime factors for all numbers from 1 to N. The least prime factor of an integer X is the smallest prime number that divides it.Note : Examples: Input: N = 6 Output: [0, 1, 2, 3, 2, 5, 2] Explanation: least prime factor of 1 = 1, least prime factor of 2 = 2, least prime factor of 3 = ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int[] leastPrimeFactor(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": 1615292571, "func_sign": [ "leastPrimeFactor(self, n)" ], "initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n = int(input())\n ob = Solution()\n ans = ob.leas...
eJzsnUuuNbtu39NIL5PYOG03Sm/JIwkQA27Yt2EguHHjGjBgGMigM4BUFblE/iTta6SXIOsA56tdqloqPSiK4p+P//mf/+v/+u//5T/9t3/745/+/M//8pc//vbnj/B3fw7X3/35j7/5+eNP//rPf/qHv/zpH//+f/zLXz5Pf+JPuv8v9/9N/75f/ve/+WEV5f+sivAUhvS5e4rD0Lv4efm9eUt9FelTR35K86eO3LT6U+vC9X9N8973fBXlqaL6KurnvfaUtk8Vbw2fVnRfRR++8vv/8den6v/TwQjX25NrduV6+3J9qgnB19M+Xf8U...
704,003
Chocolate lengths
Adam has N chocolates of unequal lengths. He wants that each chocolate should be of equal lengths. In order to do so,at each step, he picks two unequal length chocolates and takes their length difference 'd' and then he eats the bigger one andmake it's length 'd' . He stops when all the chocolates are ofequal length . ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int chocolateLength(int N , int[] A)" ], "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 Buf...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "chocolateLength(self, N , A)" ], "initial_code": "# Initial Template for Python 3\n\nimport math\n\nif __name__ == '__main__':\n t = int(input())\n\n for _ in range(t):\n N = int(input())\n\n A = list(map(i...
eJy9VU1Lw0AU7EHRnzHsuUj2e+MvEYx40By8xB5SKIjij9C/K+6Wt2uQvtqkqUPgDWzydiazeXk/+zy/XGxx83WxWNy+iKdute7FNYRsunRVBLGEaDer9qFvH++f132+K6833VvTidclfrWIC0ob63yoQVWCqgJVDaoGVC2oOlD1oBqQG3KaGC12YAcHsom2fdxKQVrIqFZCGSgPzXXTTBedBMenKxWf1awUzq9rupqAQIAnwBFgCTAEbiPCnqTza4mSiehMTCY2E5eJzyRkUo/NgdFk4huANCkCbUeelvBjRxYdqjBdmCnMFuYK84WF...
703,052
Immediate Smaller Element
Given an integer array arr of size n. For each element in the array, check whether the right adjacent element (on thenextimmediate position) of the array is smaller. If next element is smaller, update the current index to that element.If not, then-1. Examples: Input: n = 5, arr[] = {4, 2, 1, 5, 3} Output: 2 1 -1 3 -1 ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1619346551, "func_sign": [ "void immediateSmaller(int arr[], int n)" ], "initial_code": "//Initial Template for Java\n\n\nimport java.util.*;\nimport java.io.*;\n\npublic class Main {\n\n public static void main(String[] args) throws Exception {\n ...
{ "class_name": "Solution", "created_at_timestamp": 1619346551, "func_sign": [ "immediateSmaller(self,arr,n)" ], "initial_code": "if __name__ == '__main__':\n tcs = int(input())\n\n for _ in range(tcs):\n n = int(input())\n arr = [int(x) for x in input().split()]\n ob = Solution...
eJztmM1OwzAMxznwCDyA1fNAc9JPTjwGEkMcoAcuY4dOQkIgHgLeF//dVUzakrQV7bTRaP21U2MntfPh+PP8++biTMttIQ93b9HzcrWuomuKeLHkOS4qKKeMUkooJkuG5E00o6h8XZWPVfn08LKuNjI7NemSabH8EIH3Ge1RrrVQFxKQy5y6RZOBOgvEQAJ4GkhwEcfUjs6WWVtrw8DXzlGoQFHmykyZKhNlrLRKo/SYvI82T0eNusWImWMxcCruFL0ko4DlI8WjtjFZSpwR58QFQcbttd4/pylrW8qn0HQb4uYZbPDLxDb0jl5dG4/+...