question_id
int64
700k
876k
question_title
stringlengths
3
81
question_content
stringlengths
131
2.51k
dataset
stringclasses
1 value
difficulty
stringclasses
3 values
java
dict
python
dict
test_cases
stringlengths
200
208M
700,674
Pairwise Consecutive Elements
Given a stack of integers of size N, your task is to complete thefunction pairWiseConsecutive(), that checks whether numbers in the stack are pairwise consecutive or not. The pairs can be increasing or decreasing, and if the stack has an odd number of elements, the element at the top is left out of a pair. The function...
geeksforgeeks
Easy
{ "class_name": "GFG", "created_at_timestamp": 1618324801, "func_sign": [ "public static boolean pairWiseConsecutive(Stack<Integer> st)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\n\nclass elements\n{\n public static void main (String[] args) {\n ...
{ "class_name": null, "created_at_timestamp": 1618324801, "func_sign": [ "pairWiseConsecutive(l)" ], "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 l = list(map(int, input().split()))\n ...
eJytlMFKAzEQhj3oe/zk3Ehmd5PN+BCeFVc86B68pIW2IEjFh9C38OYL+mdbhIIRY7vww8LOfDvzTyavp++fZyfTc/XBl5tn85gW65W5gJEhiaPQoEUHj4AeEQpxZgYzPi3G+9X4cDdfr3YZ1+NySC9DMpsZ9kGaWUyNRASiOiKbakqfq2HiBAiIBcDlvJAvPpfh2IBQDdVSHeWpQPVUpNgk6xVhnDBOGCdddb1xSFbgYFvYBtbDdrA9bKgmSTsk79ApvIAvvoWnDR6eg+nh6Sk/RYT60UgzpIa9smV2TgPoA+2gK2w69448uXqsZGzm...
702,727
Longest Span in two Binary Arrays
Given two binary arrays arr1[] and arr2[] of same size. Find the length of the longest common span [i, j] where j>=i such that arr1[i..j] is equal to arr2[i..j]. Examples: Input: arr1[] = [0, 1, 0, 0, 0, 0], arr2[] = [1, 0, 1, 0, 0, 1] Output: 4 Explanation: The longest span with same sum is from index 1 to 4 followi...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int longestCommonSum(int[] arr1, int[] arr2)" ], "initial_code": "import java.util.HashMap;\nimport java.util.Map;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "longestCommonSum(self, arr1, arr2)" ], "initial_code": "if __name__ == \"__main__\":\n t = int(input())\n for _ in range(t):\n arr1 = list(map(int, input().strip().split()))\n arr2 = list(map(int, input().s...
eJztWs1OwzAM5sCDRLkhTSieNg14A24ckSjiAD1wCTt0EhIC8RDwvrRLQ1tSh7VaKsfNIkt2kzixP+d/n6ffN2cn+9/tdcncvclnvd0V8kpIyDQIFinTSrBImZYLIfPXbf5Y5E8PL7uixqrM+Sgz3xeiC6DaO6CqCzXZL21ZtUq4eX9L+sp1a2A6XG3+7//oN/CC06l2wX5VeKO4CX26+ow4xChffUdCwV9fouizSIwMQRAEhQ1gLEIiIzMTMaDREHbnYWaS2SmoWrTOYifh4F94sG9UMOXsNgN+M1hyOPpL7/rbKGLJ21MCic6E43H0...
702,144
Excel Sheet | Part - 2
Given a string S that represents column title of an Excel sheet, find the number that represents that column.In excel A column is number 1, AA is 27 and so on. Examples: Input: S = A Output: 1 Input: S = AA Output: 27 Constraints: 1 ≤ |S| <=7
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1617214182, "func_sign": [ "public int excelColumnNumber(String s)" ], "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 GFG {\n public static void...
{ "class_name": "Solution", "created_at_timestamp": 1617214182, "func_sign": [ "ExcelColumnNumber(self, s)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for tcs in range(t):\n s = input()\n ob = Solution()\n print(ob.Exce...
eJylkrFOwzAYhBn6IJHngvzbjv8/bIUQmMOA1QYxtBlYTIdUQkIgHgIej40HwU2DQKCLQM0UKTnf3ed7nry+Tw76J7yll8WDuo3rTaeOM0VNnKtpptr7dbvs2tXN3aYbPhnfxKcmqsdp9kMwRxISwwJUs5PT8qw6B0prHRlrtQXqUJXI01txQFWFy4s6XKGC5NiJ9Y5RZGSJ/kcCgxwgSdYGmiAXhvRmWLS9sgLho7InP0rRetZj+sF+n2OScDe7ETmxZ0KYt0Garz38NZNxktYFofaDhosWL2x0Ljmi+wtw2MWq6HtfNPtDyuFlD01R...
714,258
Another Coin Change Problem
Given three integers n, k, target,and an array of coins of size n.Find if it is possible to make a change oftargetcents by using an infinite supply of each coinbut the total number of coins used must be exactly equal tok. Examples: Input: n = 5, k = 3, target = 11 coins = {1, 10, 5, 8, 6} Output: 1 Explanation: 2 c...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1678885122, "func_sign": [ "public static boolean makeChanges(int N, int K, int target, int[] coins)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass IntArray {\n public static int[] input(BufferedReader br, int n) throws IOExcepti...
{ "class_name": "Solution", "created_at_timestamp": 1678885122, "func_sign": [ "makeChanges(self, N : int, K : int, target : int, coins : List[int]) -> bool" ], "initial_code": "class IntArray:\n def __init__(self) -> None:\n pass\n\n def Input(self, n):\n arr = [int(i) for i in input(...
eJytVV1Lw0AQFBHEf7Hcc5G9S+5y6y8RjPigefAl9iGFgij+CP2/zl2afmlqtzFw17Klw8zs7Obj4uvq8iw/t+f4cvdqntv5ojM3ZGzdWh4Op5vwSSIkkaQiCSSepCQpSJyZkWmW8+axa54eXhbdBuS9bs3bjHaRq7otcPu6dZ4KJsfkAU8WtxYLILFuSzCMKxAHHCWISwKB5JNScPJMlU+0gAd+JVNgipDP2QWbfkHRompj4o+DmkPNoeYiKwmUWUjINAY7lBCh71bB+UoSQmZeJeZKLOt6vLgihC55KrO9mV454J8CHrNc24fK9U1z...
704,152
Count numbers containing 4
You are given a number n, Return the count of total numbers from 1 to n containing 4 as a digit. Examples: Input: n = 9 Output: 1 Explanation: 4 is the only number between 1 to 9 which contains 4 as a digit. Input: n = 44 Output: 9 Explanation: 4, 14, 24, 34, 40, 41, 42, 43 & 44, there are total 9 numbers contain...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public static int countNumberswith4(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 BufferedRe...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "countNumberswith4(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.countNumberswith4(n...
eJydk00OwiAQhV30IIR1Y5hCLXgSEzEutAs32AVNmvgTE6+g97Ua08jiQYQVhHl8M4+8W/G8F7PPWp3HzfrED67rPV8yTtYRLxlvh67d+Xa/Pfb+eyWsu1rHLyUL6xWoJ1BP4k+BQoIaEiDCQAaSNA2QGGOApGrw7AKCpJKwu/dCI+lKRHGIp4SpoeXYD1I64vsEhfqIOamOE8I0O/pANj0gZ49N1ors/kd55KMXWkuUXgrHD7r4PeYEFwZkiuHmMX8B8TdhWg==
700,292
Generate IP Addresses
Given a string Scontaining only digits, Your task is to complete the function genIp()which returns a vector containing all possible combinationsof valid IPv4 IP addresses and takes only a string Sas its only argument.Note: Order doesn't matter. A valid IP address must be in the form of A.B.C.D, where A, B, C, and D are...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1619417872, "func_sign": [ "public ArrayList<String> genIp(String s)" ], "initial_code": "import java.util.*;\nclass GenIP {\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": 1619417872, "func_sign": [ "genIp(self, s)" ], "initial_code": "# Main\nif __name__ == '__main__':\n t = int(input())\n for i in range(t):\n s = input().strip()\n res = Solution().genIp(s)\n res.sort()\n if len(res):\n ...
eJytVMFKxEAM9SD4G2XOa2hm3NL6JYIrHrSIl7qHLgii+BH6vyYz6TYzkGpZZwY2j7ykmezkfZ5/Dxdncd08kXH75p6H/WF015XD3YBuU7n+dd8/jP3j/cthFNcl+T52g3vfVHlATcuIqSFuIxDrtI1grGE6zE0WwgTIEk+yMoDmR6lYv23W3hE7j02LaDUHofNADCAKs6FACBlqoEAICVGYYnISKJBiMjFHBK0LeNnmBTwfyuOZLWaO+JczgWYKLUczk03lk88o5CFVBzqLBMERqSySIvOpLFKeQt5sSkfL6EcHcRuBrSwjuG1hOgsz...
706,277
Sort a 2D vector diagonally
Given an NxM 2D matrix, rearrange such thatEach diagonal in the lower left triangle of the rectangular grid is sorted in ascending order.Each diagonal in the upper right triangle of the rectangular grid is sorted in descending order.The major diagonal in the grid starting from the top-left corner is not rearranged. Exa...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "void diagonalSort(int matrix[][], int n, int m)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*; \nimport java.io.*;\nimport java.lang.*;\n\nclass GFG\n{\n\tpublic static void main(String[] args) \n\t{ \...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "diagonalSort(self, matrix, n, m)" ], "initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n n, m = map(int, input().strip().split())\n inputLine =...
eJzt28uOHVcVBmAGPEjJ4wj1XmvfmodgjIQRA8iAickgkZAQiIeAd2UG36rOxUn6nI6SoDh2WTqWJf8un9rfvq1d1f/85b//+5tfnL9++x9/+N3fXv35zSefffrq18er9vpNO+q3h4eH12/+8frNq4+OVx//9ZOP//jpx3/6w18++/SLnL8/ngJ//+j4xgUejvbwdInj8fHRZ/ssn+kzfLpP+oRP85Hbcltuy225LbflttyW23JbbsktuSW35JbckltyS27JLbkpN+Wm3JSbclNuyk25KTflhtyQG3JDbsgNuSE35IbckOtyXa7Ldbku...
705,476
Kth largest element in a stream
Given an input stream arr[] of n integers. Find the K**th largest element (not K**th largest unique element) after insertion of each element in the stream and if the K**th largest element doesn't exist, the answer will be -1 for that insertion. return a list of size n after all insertions. Examples: Input: k = 4, n =...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int[] kthLargest(int k, int[] arr, int n)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader read =\n ne...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "kthLargest(self, k, arr, n)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n k, n = map(int, input().split())\n arr = list(map(int...
eJztl0tuE0EQhllwAW5Q8jqg6ZnqhzkJEkYswAs2JgtHQkIgDgFHYcfhqPp6HD+YkR+JYxRlelxK5Pmmu/qvrir/eP7rz4tnXG9+2x9vv04+La5vlpPXMgmzRZTQzBahkakUyZIkikonrdh3kyuZzL9czz8s5x/ff75Z9tTLILd3Wo/Z4rsh365ke4LUT2CXTO1yU9xkN8lNdKNuOjetm8Omt3vF75qR5Zinwb4L5mFrfvrQfsTVOHTqzXvjhSMz5zqxbbhK6CTYFht26sb3zu+Okbk7wed+7Jmgf2bwRVFaU7NFzYCcAT0DggYUDWgQ...
700,787
Even Odd
We've learnt about operators and other basics of CPP. Now, it's time to take another leap and learn how to use control structures that helps us choose flow of any code. Examples: Input: a = 2, b = 3 Output: 2 3 Input: a = 5, b = 2 Output: 2 5 Constraints: 1 ≤ a, b ≤ 10**8
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1617362751, "func_sign": [ "public void evenOdd(int a, int b)" ], "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": 1617362751, "func_sign": [ "evenOdd(self, a, b)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n a, b = map(int, input().strip().split())\n obj = Solution()\n...
eJylVcEKwjAM9SB+R+hZpO063fwS0YqI7uClepggiOJH6P86JZkbmq7YXDbIy+tr+tLe+o/1oPeO2bz6WZzFzh2OpZiCUNYpiQE5hhiCKE6HYlMW29X+WBKWgNYR0rqrdeIyhDYlpaEuiaZUOjHpeJJBNhmnJtGKY0ScdQRkCCkNVBFLaDAgwWAICWcdARlCSgNVxBJqDMAv10PC1RXclilNhDqWMMceAzadsyLhKkIEcqcc6O0s2Nq1wjB5Hm3VIvKfMZE+fV+m6XJNt21ak2JS76S80p2T0tT4a3A8klWn2vZFEXhNcEqVDrlxArb8...
701,290
Winner of an election
Given an array of n names arr of candidates in an election, where each name is a string of lowercase characters. A candidate name in the array represents a vote casted to the candidate. Print the name of the candidate that received the maximum count of votes. If there is a draw between two candidates, then print lexico...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1616127542, "func_sign": [ "public static String[] winner(String arr[], int n)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GfG\n{\n public static void main (String[] args)\n {\n \n Scanner sc = new Scanner(Sys...
{ "class_name": "Solution", "created_at_timestamp": 1616127542, "func_sign": [ "winner(self,arr,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 arr = input().strip().split()\n\n ...
eJztVttu1DAQ5YE3fmK0zxVqCpUQX4LEIjRJphs3vgTHSXcXgfgI+F/Gt7Tb1tuqlCdYec5Ejnd85uKJf7z8Nbx6EX4fBD98/LoSepjc6j2sqrV+t9aXptOwgN7dVHCJTS+Ilcq4OoEVbQdqHLWfzeSSrbD6zVp/X+vVtxM43OV8rfeTnADl0CHUFmeTnv10wWJccFYwWZ1H5jf4ZqpRHXXi0N9lJv3hiIu84rzA6Ox0rVHSFgLUpIM0HVrJ5rNucRZtQrKiiXBhqY2wQbuL0KEMIlAHYZo0RixGjDcuBYxp3+ZyhxtJhwXbec3bUj7Y...
703,175
Missing number in shuffled array
Given an array arr1. The contents of arr are copied into another array arr2 and numbers are shuffled. Also, one element is removed from arr2. The task is to find the missing element. Examples: Input: arr1[] = [4, 8, 1, 3, 7] and arr2[] = [7, 4, 3, 1] Output: 8 Explanation: 8 is the only element missing from arr2. In...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int findMissing(int[] arr1, int[] arr2)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass Main {\n public static void main(String args[]) throws...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "findMissing(self, arr1,arr2)" ], "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\n for cases in range...
eJzNVc1OAkEM9uDNl2j2TMx2Zjoz65OYiPGgHLysxECCMRgfQt/XtoNGyJYF5W9JvxJoOx+dr+X9/PPl4kyf62d+c/NaPbbj6aS6ggqHbaMPYK0P0M8nVA2gGs3Go/vJ6OHuaTr5zimRw/Zt2FbzASyXQ+cDRVCXisvqYt39pXXKIqX7ECbq2DxbENJskS2xZbaGTWgCSiRKKEosSjCSkN+yxFK2SdnuCjjwEIAgQoIM0m+uzNS4NBfmsoDcGG4Kd6thZuA4x4Hz4AI46i3Rk29RDgbhFVV0Hd4fZAroMF36QwGDcbJ1qCpBASfgBYIA...
702,847
Punish the Students
A Professor conducts a Computer Science paper for Nstudents. He had strictly instructed all students to sit according to their roll numbers. However when he started checking the papers, he found out that all the papers were randomly ordered becausethe students had sat randomly during the exam instead of sitting accordi...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1617890371, "func_sign": [ "public static int shouldPunish(int roll[], int marks[], int n, double avg)" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nclass GfG\n{\n public static void main (String[] args)\n...
{ "class_name": "Solution", "created_at_timestamp": 1617890371, "func_sign": [ "shouldPunish(self, roll, marks, n, avg)" ], "initial_code": "# Initial Template for Python 3\n\nt = int(input())\nfor tc in range(t):\n n, avg = input().split()\n n = int(n)\n avg = float(avg)\n roll = list(map(int...
eJy1lcFKxDAQhj0IvsZPz8sySZpk4pMIVjxoD17qHnZBEMVH8KD4us5kC0tZsrTdblto2mS+mf+flH5d//7dXOXj7lsG9+/VS7fZbatbVKbpDAzRmmQgF8m9WqFq3zbt07Z9fnzdbQ9LP2XyY4VhvEX0Gm4hD4GQyggqIBxCrsDBwDZdTfCEOJ1TS1xWAguHuukI+ZwM8uAe5ATlFcVSkUdksD8lseRSkCAlBqVlqrxMilJgD59eaJRoxUYMwNJHnA9nCVK43If4oDiFMu3t0GRz9k6SQM2Q0LdMsgTJxr0EmWekiBSynBrJIdnJQgz1...
714,134
Distinct Difference
Given an array A[] of length N. For each index, i (1<=i<=N), find the difference between the number of distinct elements in the left and right side in the of the current element in the array. Examples: Input: N = 3 arr[] = {4, 3, 3} Output: {-1, 0, 2} Explanation: For index i=1, there are 0 distinct element in the le...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1677586822, "func_sign": [ "public static ArrayList<Integer> getDistinctDifference(int N, int[] A)" ], "initial_code": "import java.io.*;\nimport java.util.*;\nclass IntArray\n{\n public static int[] input(BufferedReader br, int n) throws IOException\...
{ "class_name": "Solution", "created_at_timestamp": 1677586822, "func_sign": [ "getDistinctDifference(self, N : int, A : List[int]) -> List[int]" ], "initial_code": "class IntArray:\n\n def __init__(self) -> None:\n pass\n\n\nif __name__ == \"__main__\":\n t = int(input())\n for _ in range...
eJy1lE1KxEAQhV2I53hkPZH+y095EsGIC83CTZxFBgZE8RB6QXfewupOpyeJ1BhwTE1CBjrfq3pV3W/nH18XZ+G6/uSXm+fssdvu+uwKmW66oum0Gi9MX32kv9kGWbvftvd9+3D3tOsjIDfItf9pmKZ7bbrsZYO5gFYsgh8hATXUIrQArpgNAwvHvBKVRCyRO3Ciihc7lAKtZiBTCl5ieSGnIfEq5AVyO1Rt+YtKQJY+QZ+iT9JKOJscZJpAoqYbipw8j/BCU6J5XlzqTLFwEDWIe86PGsEMSYNwcCGK6cHdBJE0TZg3EIF4YQUqQQXI...
714,069
Minimum Platforms 2
You are in geekworld railway station. You are given train schedule as follows Examples: Input: n = 6 arr[] = {900, 940, 950, 1100, 1500, 1800} dep[] = {910, 1200, 1120, 1130, 1900, 2000} days[] = {1, 2, 2, 1, 3, 4} platforms = 2 Output: True Explanation: Minimum 2 platforms are required to safely arrive and depart ...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1676615686, "func_sign": [ "public boolean minimumPlatform2(ArrayList<Integer> arr, ArrayList<Integer> dep, ArrayList<Integer> days, int platforms)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.io.*;\n\npublic class...
{ "class_name": "Solution", "created_at_timestamp": 1676615686, "func_sign": [ "minimumPlatform2(self, arr, dep, days, platforms)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n test_cases = int(input())\n for cases in range(test_cases):\n arrival = list(m...
eJy9VcFKA0EM9eBFvPkFw56LJJmZ7a4f4Bd4EFwR0R4EWYu2IIjiR+j/mpexC2671e62dkjIJjCvSV4y7/ufRwd79js/VOPiJburp/NZduIyrmpyTORExasElUhU1ax+FVHxKkElMvyuOfqRjVw2eZ5ObmaT26uH+ez72rPH+aSq36o6ex25NlxMiBwTqsSElidAzhOo5G0w2RxMfCwdA0VVhModFwD1MWo4WMSbQhj4hX4i0EL3fVJtTrtufyni6fX9U9fVyAF/tCQrppXOklSkhb9EXgTFKcMtdC/Xe8fApha2hrR4Y5VCpUQhySi0...
703,442
Missing ranges of numbers
Given an array arr. Find the missing elements ranges (if any) in the range 0 to max element of arr.If there is more than one missing, collate them using the hyphen (-) and separate each different range with a space.If there are no missing elements then return "-1".Examples: Examples: Input: arr[] = [62, 8, 34, 5, 332] ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public String findMissing(int[] arr)" ], "initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass GFG {\n pu...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "findMissing(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 ...
eJy1VDtOxDAQpUDiGiPXG2TH33ASJBZRQAqasEVWWgmBOATchI7L4TxnFS9gJ3KEi9GTPJ838zx+O//4ujjDuf704OaZPXa7fc+uiIltx9mGWHvYtfd9+3D3tO/Hq8rfvW479rKhHwEkCkL4cBJxomqGkwjGXT4BRwKXSKCzkSpTmlNNigw5Xz7FnSRpspRKEXgT+MEaWJXtRMJHw1rKDec4Wco1KUKT8MnP2qfzLUvftI4omIhIaGJGD4MiKs+ZalgJq6YmyMBaWBemB7vgDcFHVAK4Bq6BJbAEVsDxSDSwATbAFtgCO2AH3BSNUJTP...
710,035
Array Removals
Given an array arr[] of size N and an integer K. The task is tofind the minimum number of elements that should be removed, such that Amax-Amin<=K. After the removal of elements, Amaxand Aminis considered among the remaining elements. Examples: Input: N = 9, K = 4 arr[] = {1,3,4,9,10,11,12,17,20} Output: 5 Explanation...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1646222845, "func_sign": [ "int removals(int[] arr, int n, int k)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.io.*;\n\npublic class Main {\n\n public static void main(String[] args) throws Exception {\n ...
{ "class_name": "Solution", "created_at_timestamp": 1646222919, "func_sign": [ "removals(self,arr, n, k)" ], "initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n n, k = list(map(int, input().strip().split()))\n arr = list(ma...
eJztVs2O0zAQ5sCRh/hUiVuFPGOP7fAkSBRxgB64hD3sSkgIxEPA+/LNZNsN2mRLEQt72EaxU9v1zPfjSb89/bF99iQ+r57z4fXnzYfx4upy8xKbvBsb2Bg6MhQNAyTtxo62GwWFgzWGOC+6GyvEx5VX5qztxs0Wm/2ni/27y/37tx+vLm82/robNdrpefNli1lkTnFX8zZxf+GtvA3CYRH2yl7ZZ/YlRWy2g69O0ypfcZhdyaNG7LKUgSMxaIpEuBV3KswooSY0Ak5YjgWx9XiiS6EYX4iOaDN3gWZk0pdhpDejZfSMgVOJt+QDM84x...
700,254
Largest subarray with 0 sum
Given an array having both positive and negative integers. The task is to compute thelength of the largest subarray with sum 0. Examples: Input: arr[] = {15,-2,2,-8,1,7,10,23}, n = 8 Output: 5 Explanation: The largest subarray with sum 0 is -2 2 -8 1 7. Input: arr[] = {2,10,4}, n = 3 Output: 0 Explanation: There ...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1730714045, "func_sign": [ "int maxLen(int arr[])" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass Geeks {\n public static void main(String[] args) throws Exception {\n BufferedReader br = new BufferedReader(new InputStreamR...
{ "class_name": "Solution", "created_at_timestamp": 1730714045, "func_sign": [ "maxLen(self, arr)" ], "initial_code": "if __name__ == '__main__':\n t = int(input())\n for i in range(t):\n arr = list(map(int, input().strip().split()))\n ob = Solution()\n print(ob.maxLen(arr))\n ...
eJxrYJm6gIUBDCJmAhnR1UqZeQWlJUpWCkqGMXkGSjoKSqkVBanJJakp8fmlJQipupg8pVodBVT1pjjUG+BQb6hAsg0xebqGCkAEgrg047LOBGQjWK+uIYlazWD2IiESjTAG2m5gYADUCCJJdbuhAZLj0QgSjbIA+QXkBlMo1oUTEAfCuKQ6MSbP0tKSFE1gZ+DQgCMISDGeeKMN4GFClscVSE7HyEmROvFHUeyREAtmUNspzA0oGRlnQQPTHTtFDwCYYF0R
712,029
Maximum Stone Removal
There arenstones at some integer coordinate points on a 2D plane. Each coordinate point may have at most one stone. Examples: Input: n=6 [[0 0] ,[ 0 1], [1 0] ,[1 2] ,[2 1] ,[2 2]] Output: 5 Example: One way to remove 5 stones are 1--[0,0] 2--[1,0] 3--[0,1] 4--[2,1] 5--[1,2] 1 <= n <=1000 0 <= x[i], y[i]<= 10**4 No tw...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1662179442, "func_sign": [ "int maxRemove(int[][] stones, int n)" ], "initial_code": "import java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n Scanner sc = new Sc...
{ "class_name": "Solution", "created_at_timestamp": 1668578115, "func_sign": [ "maxRemove(self, adj, 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 adj = [list(map(int, input().split()))...
eJzt2EGOJTkRxnEWXAPpqdYjlI4IO8KcBImHWEAv2BSz6JGQEIhDwMnYcRrK/8iOclWRVc1qEPQsLI/0stP5q/jCzvzrT//+z5/9hP9++Y+nya/+9PD7x+9/+Pzwi9tDuz+24/543BjW/61ZWzNZM1kzXTNdM1szu7WH724Pn/74/afffv70u9/84YfP5782749/uT8+/Pm726tb9LqF1C2kbiF1C6lbPM36mvU1G2s2cmYX9252cXN5fr5eN+91814373XzXjfvdfOnma+Zr1msWazZXLN561eruiKRZxKtVWmtSmtVWqvSWpXWqrRW...
712,427
Candy
There are N children standing in a line. Each child is assigned a rating value given in the integer array ratings.You are giving candies to these children subjected to the following requirements: Examples: Input: N = 3 ratings = [1, 0, 2] Output: 5 Explanation: You can allocate to the first, second and third child wi...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1666676268, "func_sign": [ "static int minCandy(int N, int ratings[])" ], "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": 1666731301, "func_sign": [ "minCandy(self, N, ratings)" ], "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 ratings = list(map(int, input().spl...
eJytkzsOwjAMhhngHlZmhPJo0sLAxh2QCGKADiyBoUhICMQh4L7YKUUgaiiPuq2sqv78J79zbJ9HnVa8xkNMJjuxDOtNIQYgtA/WBwMGFGhIfKAbM0O56ILIt+t8XuSL2WpTXGv6Phx8yOJb7Ltwh1M+OB8IpSPEsBCuPKNyBwmGRYAGxSKUZRhKEuQpeJBkQLjSPmSQoiCLgl7LSTg5KW0wVsYlOUhZguZ0xAVJKLVQZJjjB8Wr0Y5j4UMyaElluBLIo0wdSjJ/13Qk8dXFm9DAg/StCbrWBOzbWC25ZX+xC6oz4L4+BLcZfmULt2HP...
703,003
Palindrome SubStrings
Given a string s, count all palindromic sub-strings present in the string. The length of the palindromic sub-string must be greater than or equal to 2. Examples: Input: n = 5 s = "abaab" Output: 3 Explanation: All palindromic substrings are : "aba" , "aa" , "baab" Input: n = 7 s = "abbaeae" Output: 4 Explanation: ...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1730966612, "func_sign": [ "public int CountPs(String s)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GfG {\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in)...
{ "class_name": "Solution", "created_at_timestamp": 1730966612, "func_sign": [ "CountPs(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\n solObj = Solution()\n print(solObj.Coun...
eJzdVsGO0zAQ5cCVf6hyXqFNW+jCge9AwghN4kk2kjO23DSbgpD4CPhfxnYXLRt7N9l2qUSbVnYivxnPe2/iHy9/fXj1wn8+bnjw6VvWkNl12ftFthJkocQS7DDsh0FQ2fRN2YKEVhBpTRYrtG6QXSwyHAyWHcovetcdADaC1oLyS0HZ94vFHeSlIChKKcsCsKrrCnkORVHyLUR3Nw34dgTGIYb91z3/AipWlccIMx74pyEC8GQ/JPHXHv+NoM0oSu6jMNChJDf6Jp3kvbWrkEpY7xJDheYaqCPGuQYlqG4scNqdtnwlcBmFrzxWTAOq...
701,116
Mother Vertex
Given a Directed Graph, find a Mother Vertex in the Graph (if present).A Mother Vertex is a vertex through which we can reach all the other vertices of the Graph. Examples: Input: Output: 0 Explanation: According to the given edges, all nodes can be reached from nodes from 0, 1 and 2. But, since 0 is minimum among ...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int findMotherVertex(int V, ArrayList<ArrayList<Integer>>adj)" ], "initial_code": "import 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": [ "findMotherVertex(self, V, adj)" ], "initial_code": "# Initial Template for Python 3\n\nimport sys\n\nsys.setrecursionlimit(10**6)\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n V, E = map(...
eJytVMtOxDAM5ID4DivnBcVN0gdfgoQRB+iBS9hDV1oJrbQfARdu/CmxU8FuS1Y10EMUOePxjBN3f/72cXEm38172ty+mKe43gzmGgxSRAsYKKY17aGiWIHlxVF04Cl6SKcBaoo1NBQbaCm20FHsGGdzTNIElw7MCky/XfcPQ/94/7wZxloJbXYrOK7eMPHp2gW6S/yJr4YjL4cOnJIqsLVDad+qxLjEvM4uVoCuxFrsM9p8TZyEXNxr29wCVgvLijc5lZhkNEqXAdD/0SXrHbuFTuhUCtL1WLUCyZCdxJrxedY5Q3KFRfiE2aplTWdt...
700,803
For Loop- primeCheck - Java
What do you do when you need to execute certain statements more than once? You put them in a loop. Loops are very powerful. The majority of coding questions need loops to work. You can't even input test cases without loops! Examples: Input: n = 1 Output: No Input: n = 2 Output: Yes Constraints: 1 <= n <= 10**5
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public static String isPrime(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": 1708151628, "func_sign": [ "isPrime(self, n : int) -> str" ], "initial_code": "import math\n\nif __name__ == \"__main__\":\n t = int(input())\n for _ in range(t):\n n = int(input())\n obj = Solution()\n res = obj.isPrime(n)\n ...
eJxrYJlqyMYABhFaQEZ0tVJmXkFpiZKVgpJhTB4QKekoKKVWFKQml6SmxOeXlkAl/fJj8uqAsrU6CqhajHBqiUwtxqHHmAw9JqQ7zdLS0sKSDKsMDUCAdPvI0AK2ipzgAPrNEnds4fGbGRmOBMeYEZgBCdMYQyACRQk5ZkGMg7oFu6lkpEMTJLNBhuaR6zy4V2FxQx1fY4QgRIyicIQ4CGgscoASZR21Qh27TWAjwVECy4MIu2NISQQ0TF90jBVciRPkPmz25+GPJ3JjKSYGZ7om7NPYKXoAEhL+Gg==
874,880
Set Matrix Zeroes
Given a Matrix arr of size n x m, the task is to set all rows and columns to zeroes if a particular element is zero, in constant space complexity. Examples: Input: arr[][] = [[1, 1, 1], [1, 0, 1], [1, 1, 1]] Output: [[1, 0, 1], [0, 0, 0], [1, 0, 1]] Explanation: Input: arr[][] = [[0, 1, 2, 0], [3, 4, 5, 2], [1, ...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1727681525, "func_sign": [ "public void setMatrixZeroes(int[][] arr)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) throws Exception {\n ...
{ "class_name": "Solution", "created_at_timestamp": 1727619498, "func_sign": [ "setMatrixZeroes(self, arr)" ], "initial_code": "import sys\n\n# Position this line where user code will be pasted.\nif __name__ == \"__main__\":\n input = sys.stdin.read\n data = input().split()\n\n idx = 0\n t = i...
eJzt20+qXNcRwOEMvJDijU24p/6XB1mHIQoZJBpkongggyHEeBHxRjLL7vKrlmwHrGf5aRIM1zxLBtc73V3fOXWquPR3n33/nz/87vHPl//mP/74j6e/vfnq67dPX8jTefXm/Y/wx/Xt0+fy9Pqbr17/5e3rv/7571+//Sns21dvnv75uTz7u+eTf/f6hBfWdz+iu8L1WOa5JXT//7V/fGylS84vrnS9C/oVK52PrPRT0AdXsnc/Yo+Xe//+f/zr+bf3s9APrX898+sffCPXu3+PqJi4hKSUtAxqcvgAKsfkuJyQk3JKTssZUVLF7/Ax...
705,463
Interesting Series
Given a series of numbers 6, 14, 36, 98, 276... Identify the pattern in the series and help to identify the integer at Nth index. Indices are starting from 1.Note: Calculate the answer modulo (10**9+7). Examples: Input: N = 2 Output: 14 Explanation: 14 is the 2nd integer of the Series. Input: N = 8 Output: 6818 Exp...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static Long findNthNum(int N)" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader r...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "findNthNum(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.findNt...
eJylVLtOxEAMpID/iFKfkF/r9fIlSARRQAqacEVOQkIgPgK+h47vIhtyRCfkDTlcrZLM2DPjzevp++fZyViXH8Ph6qm+77a7vr6oamw6BICmqzdV3T5u29u+vbt52PXT+yiBEQWk6V6Gj5431SE45XLRScgoobKDDlDqbUkpBgNz0DGXi9aYgqGwh0ZiCb5utkiIpJ5ui+qj1RiMyZ08W14QHkiUQkTXNmHCgunAwELRQXMuF82sgZDNC9xy+b0HbAJgz7bZ97L9Hn5SPiV/tAXj1s50/gYqoYTkyvnFsxjtEuPIVGb2ubPx5K7sZNrR...
702,963
Convert a list of characters into a String
Given a list of characters, merge all of them into a string. Examples: Input: N = 13 Char array = g e e k s f o r g e e k s Output: geeksforgeeks Explanation: combined all the characters to form a single string. Input: N = 4 Char array = e e b a Output: eeba Explanation: combined all the characters to form a singl...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public String chartostr(char 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 Bu...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "chartostr(self, arr,N)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n\n for tcs in range(T):\n N = int(input())\n arr = input().split()\n ob =...
eJzdltlO20AUhnvRiz7GhwN3qDLZ6RX7vm8J1FUVLxCzjA2xQ+KqVR+hF0W8bocJQqHKcVWkSm1nbMvSzH/+s/zH46+v7+7fvDKj+U2/vP9khSpOE+sd1pSj9NVylDWJFfTiwEsC/2OUJo/reuWLXvw8yU8g29Yw/vEph/2nh5DWoqMyMtGtLJNw1YdquHj4BJxyRpuQcy645ApFRMw1N3RISOlyS49+DlHL9fzg9Kwdnl9cXqkovr7pJGn3tteXHKhoOcwyxzwLLLLEMiusssY6G2yyxTY77LLHPgccckSDJsec8JsY0eHZufmFxaXl...
709,900
Minimum Sum of Absolute Differences of Pairs
You are given two arrays Aand Bof equal length N. Your task is to pair each element of array Ato an element in array B, such that the sumof theabsolute differences of all the pairs is minimum. Examples: Input: N = 4 A = {4,1,8,7} B = {2,3,6,5} Output: 6 Explanation: If we take the pairings as (1,2), (4,3), (7,5), and ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1644848454, "func_sign": [ "long findMinSum(int[] A,int[] B,int N)" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nimport java.util.Collections;\nclass GFG{\n public static void main(String args[]) throws IO...
{ "class_name": "Solution", "created_at_timestamp": 1644835170, "func_sign": [ "findMinSum(self, A,B,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().strip().spli...
eJzNVM1OwzAM5sCBx7B6nlD+HCe8CEgUOMAOXMoOmzQJIfEQ8L44adIyaGizXfAmxU3qL/bnz30//7y/OIt2c83O7Wvz3G122+YKGtl22HZSZAOfbfDc4NHgWY4BBRoMYLOCZr3frB+366eHl902IZscxPjN2wp+XYocrBlEzmOJKYiQgwAlQAswAlCA5fds9Ezc5TMpaiCJITFGIvTYCCJkyg98oOIBH+tSonqyWMd/sECM5vuiw4bnDQuJhZosDxtW4Qai02+maX6yDtlzgZEFThwBESwCITguDScaAiTAsapiGoVLcbJKF7ONcbGE...
707,909
Find the String
Given two integers N and K, the task is to find the string S of minimum length such that it contains all possible strings of size N as a substring. The characters of the string should be from integers ranging from 0 to K-1. Examples: Input: N = 2, K = 2 Output: 00110 Explanation: Allowed characters are from 0 to k-...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1624428064, "func_sign": [ "public String findString(int n, int k)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG{\n static class FastReader{ \n BufferedReader br; \n ...
{ "class_name": "Solution", "created_at_timestamp": 1625244857, "func_sign": [ "findString(self, N, K)" ], "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, K = map(int, input...
eJydk00KwjAQRl30IEPWRZofa+Il3IlgxIVm4SZ2kYIgiofQ+5rGSEH4Cm1WhfD6vZnJPIv3ppils13Hj92NnX3TBrYixq3nJFhJzF0bdwzudLi0IV8K6x/Ws3tJ/4QBhAGEgIRGIRJq8QoiElWCxCQUW0oOGIXNUIyCZlpBBJnVixpDGkCqMkiOJkxH0LcqBA5z1ubY8T+Ibw+10kjMdKNGGJozJdn4Ds3YBUngxPJyjcgWycbIvrPSDIZzgZeubxeJbgOgyK/Z+9f8AzH/VfQ=
701,211
Trapping Rain Water
Given an array arr[] withnon-negative integers representing the height of blocks. If width of each block is 1, compute how much water can be trapped between the blocks during the rainy season. Examples: Input: arr[] = [3,0,0,2,0,4] Output: 10 Explanation: Input: arr[] = [7,4,0,9] Output: 10 Explanation: Water trap...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int trappingWater(int arr[])" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass Sorting {\n public static void main(String[] args) throws Exception {\n BufferedReader br = new BufferedReader(...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "trappingWater(self, arr)" ], "initial_code": "# Initial template for Python 3\n\nimport math\n\n\ndef main():\n t = int(input())\n while t > 0:\n arr = [int(x) for x in input().strip().split()]\n obj = Solu...
eJylU0sKwjAQdaFLdx5gyLpIJmlEPIlgxYV24Sa6aEGQiofQ+5qktn4nNTElZKDzJm9e5p3719Gg59Z8aILFkW31vizYDBhmWgIHBAHKbDSxzDRLgOWHfb4u8s1qVxZNssj0yfytEngtYeESUlAklBNIZVDSXhyM5I6sgPq0TQiyxpTkXaPbTVZISRbuC2aPvF720ntIy94mkEL8LX9MCw7XTA96H1H5avipI0kdgWIRpQOPm0MMzAekhvfxiiqkJieSuy3zPgA+C01+b+ezn0hzPLuDW1k6LfJdIBLGquVlfANj1nVj
706,065
Transfiguration
Professor McGonagall teaches transfiguration at Hogwarts. She has given Harry the task of changing himself into a cat. She explains that the trick is to analyze your own DNA and change it into the DNAof a cat. The transfigure spell can be used to pick any one character from the DNA string, remove it and insert it in th...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1618658494, "func_sign": [ "int transfigure(String A, String B)" ], "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 Buffered...
{ "class_name": "Solution", "created_at_timestamp": 1618658494, "func_sign": [ "transfigure(self, A, B)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n line = input().strip().split()\n A = line[0]\n B =...
eJxrYJm6gZUBDCJWAhnR1UqZeQWlJUpWCkqGMXmOCo5KOgpKqRUFqcklqSnx+aUlUEmDmLy6mDylWh0FNB1ALSTrUXDCoUPXEKc1UKAAY5BsgpOzi6ubu4enl4KXp4e7m6uLsxMuQyzxmKGAR58xPrsVQKQb+c729vH18w9QCAwKDgkNC4+IjEKXotRohMkKUZER4WGhIcFBgQH+fr4+3gRDzMgUZ8Q5OTk7u7i4uiqACGdnkAAOQ8xwmZFHRoKBBDmIRVoowrlkxRaGbyGZCqeXSY/3cCpEPIorFZCdSbo7cWd/wn4LwogOJ+p5jAy/...
712,538
Shortest Job first
Geek is a software engineer. He is assigned with the task of calculating average waiting time of all the processes by following shortest job first policy. Examples: Input: n = 5 bt = [4,3,7,1,2] Output: 4 Explanation: After sorting burst times by shortest job policy, calculated average waiting time is 4. Input: n = 4...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1666854814, "func_sign": [ "static int solve(int bt[] )" ], "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[] args) throws I...
{ "class_name": "Solution", "created_at_timestamp": 1666816026, "func_sign": [ "solve(self, bt)" ], "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 bt = list(map(int, input().split()))\n ...
eJylVEsOgjAQdaH3mHRNDJSWjycxEXWhXbipLCAxMRoPofe1UzQKOuXXwkAyeW9+L3ObPtRsYs9yY35WZ3bQeVmwBbAg0/gwD5g65WpXqP32WBYvr5/pa6bZxYMGxMcXUkgghggkCAiBA0UTRASPRBo8kOKxNrE2tjaiCNEpnMkh6SBLhBTS+IiI3ASswBSaQkqLrC4B5a4y4edS6bsS4GZ6AmR/aNvgXVH9T8v/f6h+WGdbUyjhuHCNeXxLacBYaxVVwu5SnpV20jHNmvTGJv0mH80T4HjCvjtFDlxDw6AGElOCd2+9FtD6Pn8CRbqQ...
703,000
Form largest number from digits
Given an array arr[] of numbers from 0 to 9. Your task is to rearrange elements of the array such that after combining all the elements of the array, the number formed is maximum. Examples: Input: arr[] = [9, 0, 1, 3, 0] Output: 93100 Explanation: Largest number is 93100 which can be formed from array digits. Input:...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public String MaxNumber(int arr[])" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "MaxNumber(self, arr)" ], "initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n arr = list(map(int, input().strip().split()))\n ob = Solution()\n ...
eJy1VMtKBDEQ9CB+hjQBb4uk845fIjjiQefgZdzDLCzIih+h/2sl7K6rsx1Uxm4Cc5hUVVd35/X0/eLspMb1OT5untXjsFyN6ooUd0OmRJECeXJkyRCTVgtS/XrZ34/9w93Tatz+nFMM3lnDuhteukFtFvQVytMkBSi/DwHKQotDFpCAjBQFqBhD8N45awUoTZMUoPQ+BKhMxa3iV6yqfHWt+FacK95xAz7nlD7VGsMsEnGFMjUt7cxwW1fDzpKGKeABEZhABS6QscCVKpYHh0Z5zebbhjNM347oAoJZ1mNQZ4DJGjAWuiLlvw6kBYTD...
714,335
Total Traversal Time
Given two arrays arr[ ] and penalty[ ], each of size n.All elements in arr[ ] are in the range of 1 to n. You have to traverse arr[ ] from start to end while following the given conditions. Examples: Input: n = 4 arr[ ] = {1, 2, 3, 3} penalty[ ] = {1, 2, 3, 4} Output: 5 Explanation: For i = 1, traversal time = 0 seco...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1679378268, "func_sign": [ "public static long totalTime(int n,int arr[],int penalty[])" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.io.*;\n\nclass GFG {\n public static void main(String args[])throws IOExceptio...
{ "class_name": "Solution", "created_at_timestamp": 1679378268, "func_sign": [ "totalTime(self, n : int, arr : List[int], penalty : List[int]) -> int" ], "initial_code": "class IntArray:\n def __init__(self) -> None:\n pass\n\n def Input(self, n):\n arr = [int(i) for i in input().strip...
eJzVVstOwzAQ5MCJrxjlXCF77TwMN74CiSAO0AOX0EMrISEQHwH/y24ebhripmloVeKtEifxzuxkPern+ffNxVl53F7zxd1b9FwsVsvoCpHOC634B+JhYBEjQYoMLi8cn1Kexnzb8GMNeTWaIZq/LuaPy/nTw8tq2SRK8uKDn77P0EkfS/oGQCAERGAEiKHyogvjGAiaF/HEQFtIjgCupQAuSVkK20I3IBVOBSVoJaCcbHmXyvcUfgtCnIXZZtApRIEAydSGSMaV9hvK95H0PD1Vz9ZKGpAFMSdWucsKOxSy5bO6AHWjKol82FaYVlAr...
701,161
Number is sparse or not
Given a number N.The task is to check whether it is sparse or not. A number is said to be a sparse number if no two or more consecutive bits are setin the binary representation.Example 1: Examples: Input: N = 2 Output: 1 Explanation: Binary Representation of 2 is 10, which is not having consecutive set bits. So, it...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1618484304, "func_sign": [ "public static boolean isSparse(int n)" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass Main {\n\tpublic static void mai...
{ "class_name": "Solution", "created_at_timestamp": 1618484304, "func_sign": [ "isSparse(self,n)" ], "initial_code": "# Initial Template for Python 3\n\nimport math\n\n\ndef main():\n T = int(input())\n\n while T > 0:\n n = int(input())\n ob = Solution()\n if ob.isSparse(n):\n ...
eJxrYJlqzcIABhEmQEZ0tVJmXkFpiZKVgpJhTJ6hko6CUmpFQWpySWpKfH5pCUKqLiZPqVZHAVW9AYnqTUhUb2iKQ4MBLg1mJNpgbESiBjNjEp1kRrKnjcxJ9bWRBel2kBO8JLvMzISMVGUISlm4IhJ3GJgbgi0kJ9VAEDRMTMhxrxkIm5kYkx53MM3mZOk2wJfCCNoJtpLEwIudogcA2Q5UHw==
705,073
Sum of product of all pairs
Given an integer N and an array of N integers. Calculate the sum of products of all pairs of integers of the array.Note: Since the answer can be large, return the answer modulo10**9+7. Examples: Input: N=3 A=[1,2,3] Output: 11 Explanation: 1x2+2x3+1x3=11 So, the answer is 11. Input: N=3 A=[2,2,3] Output: 16 Explan...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "int productOfPairs(int N, int A[])" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedRe...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "productOfPairs(self,N,A)" ], "initial_code": "# Initial Template for Python 3\n\nimport math\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n A = list(map(int, inpu...
eJy1lM1OwzAMxzkg8RpWzxOKnW+eBIkiDjAJLt0Om4SEQDwEvC+u026UzV1XiUhe42ix4//Pyefl9+rqQsbtM0/u3qqXZr3dVDdQYd2EukEjA7KM8klwdLVuqgVUy9f18nGzfHpYbTddpBxyyt6QqZsP/tP7AoZp/D4NwsFMDetzzMagEhR5I5J1PkDwzhKCOBGiuCBOgiQuiMOFiAviGJBfVPOTMykFIq+cIElZQGyWzbF5tsAW2dJYaS6U0o8GdixZEenYR8fQQmIOUQm7o91jHUbvFvFUEu8j5ZROY+nEnumpJ7BoKaOzGhYuf99l...
701,416
Ways to write n as sum
Given a positive integer n, the task is to find the number of different ways in which n can be written as a sum of two or more positive integers. Return the answer with the modulo 10**9+7. Examples: Input: n = 5 Output: 6 Explanation: 1+1+1+1+1, 1+1+1+2, 1+1+3, 1+4, 2+1+2 and 2+3. So, a total of 6 ways. Input: n = 3...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1617791044, "func_sign": [ "int countWays(int n)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass Main {\n public static void main(String args[]) throws IOException {\n Bu...
{ "class_name": "Solution", "created_at_timestamp": 1617791044, "func_sign": [ "countWays(self,n)" ], "initial_code": "# Initial Template for Python 3\n\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 r...
eJyd079qwzAQBvAOfhCj2ZQ7WXfS9UkKUciQeujienAgUFpCtu7J+yaO86cdPg31ZPD9/ImP0646/lRPl+d1f35ZfLr3ftiM7qV2nHt2Te267dCtx+5t9bEZr58o99+5d19N/Xfeg3kG80wABCQECU/Be4E5iLGRqHnDeVBqStEiFzIRjWTBVBVRM0O9qFlokzcoBWUat0mCKJARNxsTJYuGJBe1wH6K7WJG9MBIt8SBlQTVNP8De7TfU+xMheDu4qNPMGcsYeyc+E9W3H9kb+xX13CbTeP5MrSpvB9cuu/3zpaH5xOQTmQC
702,884
Farthest Index
Given a positive integer x and an array arr of positive integers. We need to find the farthest index at which x is present. Ifany occurrence ofxdoesn't exist, then return -1. Examples: Input: arr[] = [7, 42, 5, 6, 42, 8, 7, 5, 3, 6, 7] and x = 7 Output: 11 Explanation: The last index contains value 7. Input: arr[] = ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int findIndex(int[] arr, int x)" ], "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": [ "findIndex(self, arr, x)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input())\n\n while t > 0:\n arr = list(map(int, input().split()))\n k = int(input())\n ...
eJztWktOwzAQZcFBhqwLsp04H06ChBELyIKN6aKVkBCIQ8Bt2HExbE8cQrGTllYNJePFe7aTesYf5T1ZfTl++zg5cuXi3VQuH5M7PV8uknNIuNKc2QKVLRBo+DeUTmaQ1A/z+mZR317fLxfNGFLpZ/PwaQadgYX5GQhIIQMJORRQgh1QadlG/BbLQtntKpR2TwbCpqHgPBy8aViUyC6dyPi8jA3NOolj5iZ1RwVSjiSbKcRj5LEQIs1MekVZmWXarK50Q7FpsVBMs4zSzolgSoCbbk6pO84EEwLcdKUFswWIiA6N/OHtkTrUulWOSTp4...
706,237
Minimum XOR value pair
Given an array ofintegers of size N find minimum xor of any 2 elements. Examples: Input: N = 3 arr[] = {9,5,3} Output: 6 Explanation: There are 3 pairs - 9^5 = 12 5^3 = 6 9^3 = 10 Therefore output is 6. Constraints: 1 <= N <= 10**5 1** <= arr[i] <= 10**5
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1619459760, "func_sign": [ "static int minxorpair(int N, int arr[])" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])throws IOException\n {\n BufferedReader read = new Buffer...
{ "class_name": "Solution", "created_at_timestamp": 1619459760, "func_sign": [ "minxorpair(self, N, arr)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n arr = input().split()\n for it...
eJytVUFuFEEM5IB4R2nOEWq73bY7L0FiEQfYA5clh40UCUXiEeET3PghbpNDULqVZURppjRSd7s8ZXvm++sfv968Srz7GQ/vv21fTje35+0aGx1OfDgVlO0K2/Hu5vjpfPz88evt+XG9HE7b/RWenegDoDKwOKp1dpbKuFnARRxSusKpM0irCyqbOrS1qqBKxRisTCJoLOy+kKqxcSYWGRBXaVDzXpBJr0LEFprFaCNf8WYaKXejxhDqUovAq7sWj9zNjElXoUmasc+Ca5j59P3wgtRCwVylTh2QMGHl6SJY9xCcxbJHNyO7wYbkKOLg...
706,426
Subsets
Given a set of positive integers, find all its subsets. Examples: Input: array = {1, 2, 3} Output: // this space denotes null element. 1 1 2 1 2 3 1 3 2 2 3 3 Explanation: The following are the subsets of the array {1, 2, 3}. Input: array = {1, 2} Output: 1 1 2 2 Explanation : The following are the subsets of {1...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1729589956, "func_sign": [ "public ArrayList<ArrayList<Integer>> subsets(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 BufferedReade...
{ "class_name": "Solution", "created_at_timestamp": 1729589956, "func_sign": [ "subsets(self, arr)" ], "initial_code": "# Example to simulate input/output behavior:\nif __name__ == \"__main__\":\n t = int(input()) # Number of test cases\n for _ in range(t):\n # Reading the array input as spa...
eJztXM2O5DQQ5sCDWH1eocR2OgkvwRWJQRxgDlyGPcxKSAjEQ8B7cuOK689VZScNo9mVtlnvdtv177Ljn4zUn3///M+/v/oM/339VyG++eXy49Pbd8+XL8MlPTzNIYYU8sPTEq4PT2vYwh7m6fImXB5/fvv4/fPjD9/99O6Z7Ys5erCb8QYCKxSyqBTFFA3ZDI0Ki0z5/PbwVFrmxq/Mr5gHJ6M5EUU1ikUIZTFHYzElwyIgFr4l9uXXN8F0H/oxhzmGGbLOYV7CfD3v+szmzmumCoQsSdyNOXNQjU0UVCBkyfUoNWir9Kx0Yw9xCrGM...
700,542
Play with an array
Given an unsorted array arr, rearrange the array elements such that the number at the odd index is greater than the number at the previous even index. Examples: Input: arr[] = [5, 4, 3, 2, 1] Output: true Explanation: The given array after modification will be as such: 4 5 2 3 1. Input: arr[] = [4, 3, 1, 1] Output:...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1617794952, "func_sign": [ "String formatArray(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 st...
{ "class_name": "Solution", "created_at_timestamp": 1617794952, "func_sign": [ "formatArray(self,arr)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input())\n\n while t > 0:\n arr = list(map(int, input().split()))\n ob = Solution()\n ...
eJy1lE1KBDEQhV2IV3Anj6wHSeW/PYlgi4i2IEg7aDcIongIva9VSSsiM2hnZhJ4ySaVx/cqedv/ODrYy+P0kDdnz+q2X46DOoGiticNo2E1nIbXCBpRI2k0Wi2guqdldzV01xf34zCdGR7Gru1f2169LPCrFkjnAYMmD9iySfOLeayYa8rcXN49rjU1WZoMFTtliWUJ8805g+RgCMHCWoQIaip4CSkt9AW/8JcAJAGJQDLQmWhFZWOdh0iASIRIgkgDEb6FhSDCabHY+ddEztejAQdPcCAzv4RkklJCjBEhBHjv4ZxjqhbGGC5M84sa...
705,657
Optimal binary search tree
Given a sorted array keys[0.. n-1] of search keys and an array freq[0.. n-1] of frequency counts, where freq[i] is the number of searches to keys[i]. Construct a binary search tree of all keys such that the total cost of all the searches is as small as possible.Let us first define the cost of a BST. The cost of a BST n...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int optimalSearchTree(int keys[], int freq[], 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...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "optimalSearchTree(self, keys, freq, 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 keys = input().split()\...
eJy9VctKA0EQ9CD4GRZ78BRkenpe65cIrnjQHLysOWxAEMWP0P+1e5JoNtJxNWA2kH1NdXVV9eT1+P3s5Kh+Lk/l5Oqpue8Xy6G5QENdH+ULcqAI7+DlkuFBCEjNDM38cTG/HeZ3Nw/LYb2Ifde/dH3zPMMYKshah+AQHZLrekEVyHrLgKLiDKwky4UHC4+IpBw/DwMrW1Dc9RktiJSRUlJOJiPnLBzSloRRxAoOxKoaZVA7YivPi75h1gjRKCH3vSov62s18SSCI4K0bfXN0ULLO9aqFRxXKrQOxSGrUWqX7RC1lh5Fo5K0UV91KPAi...
703,703
CamelCase Pattern Matching
Given a dictionary of words where each word follows CamelCase notation, print all words (in lexicographical order) in the dictionary that match with a given pattern consisting of uppercase characters only. Examples: Input: N=3 Dictionary=["WelcomeGeek", "WelcomeToGeeksForGeeks","GeeksForGeeks"] Pattern="WTG" Output: W...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1731487104, "func_sign": [ "public List<String> camelCase(String[] arr, String pat)" ], "initial_code": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int t...
{ "class_name": "Solution", "created_at_timestamp": 1731487104, "func_sign": [ "camelCase(self,arr,pat)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n arr = list(map(str, input().split()))\n pat = input()\n ...
eJy1VF9LwzAQ90Hwa5Q+D6FTQXxb0lIf5h/Yw6S7Id2adsV6GV2Gigh+CP2+XtKObVDd4raS3F3S3N/8Lp/H3/HJkfkeIhIG726O07lyrxzXA6TRoeG2HFe8TsVYieRRzlV9YDAEdD9azrpOG5DHz6Lg8UyQyGn2rAycG6eM9AB9wCiy0j4D7E1kqboSMyMAalFPURo6U/WRel3Sia6VjwuKUIfIqvx8ijIIaI9xP7AN9gbwFvAO8N66SCOeBGk4IWnMRJgTT9iEp8QFy7hes9A6Lzb2RWpMJpqNhDGYsoRrFpDPKlErw5eA16IoZF+W...
704,025
Sum of first n terms
Given an integer n, calculate the sum of series 1**3 + 2**3 + 3**3 + 4**3 + … till n-th term. Examples: Input: n = 5 Output: 225 Explanation: 1 **3 + 2 **3 + 3 **3 + 4 **3 + 5 **3 = 225 Input: n = 7 Output: 784 Explanation: 1 **3 + 2 **3 + 3 **3 + 4 **3 + 5 **3 + 6 **3 + 7 **3 = 784 Constraints: 1 <=...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "long sumOfSeries(long n)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader read ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "sumOfSeries(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.sumOfSer...
eJzVVsFOwzAM5cCNn5h6npDjOE7CF3DjikQRB9iBS+GwSUgIxEfA/+I0WbduTddO2xBRlaZW+uznvDj5Ov+5uTir2+21DO7ei+fqdTEvriaFLitVVkZ6KKtiOilmb6+zx/ns6eFlMU9zZMJnWSGa+q0hDYqP6WQNCQUGpJUVeWl5NMMYHoC6i78IXLCTtlv2DTch1DpcqLvQoyaxGNKo8l6JEh4aA8FB+gAZomm8GQdWAxOyVn5JGZVlR2isl58ZrGXVFZpKGRhJfBulTmAPyoA06c28UJyZQR1FmwVLo8ARQD4C0YNGAZBAWDvKukbn...
702,704
Mega Sale
Mr. Geek is a greedy seller. He has a stock of some laptops comprising both useful and useless laptops. Now, he wants to organize a sale to clear his stock of useless laptops. The prices of laptops are arri each consisting of positive and negative integers (-ve denoting useless laptops). In a day, he can sell almost m ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int maxProfit(int m, int[] arr)" ], "initial_code": "// Initial Template for Java\nimport java.util.*;\n\n//Position this line where user code will be pasted.\npublic class Main {\n public static void main(String[] a...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "maxProfit(self, m, arr)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input())\n for _ in range(t):\n k = int(input())\n arr = list(map(int, input().split())...
eJylVM0KwjAM9rAHCT1b6c+qzicRrHjQHbxUDxMEUXwIfUVvvoNpV4aDpVjMuqVbky/Jl7B78XwXoyDLF25WF7Z3x1PDFsCkdcY6LkUQ4FWQqOdRz6KeWsfGwOrzsd429W5zODURpgznwrobmlzH0I+grRMQLxKCcg7pgQKuoQRuSP+K8PdLgBKg82NLPOAGuPQ3sqN8CQZwi1/wRdHpGApTfdEdNQnSnQ8ilZ7WLi8SRCfagszSi0ZMlGb8FPlHW12ytFTHI0O9eaygm1OTJk61AzkUgEvCh2o/1eBEV/5qSxlmVncw+WMbUsjxwTC/...
703,965
Maximize the volume of Cuboid
Given the sum of length, breadth and height of a cuboid. The task is to find the maximum volume that can be achieved such that the sum of sides is S. Examples: Input: S = 8 Output: 18 Explanation: All possible edge dimensions: [1, 1, 6], volume = 6 [1, 2, 5], volume = 10 [1, 3, 4], volume = 12 [2, 2, 4], volume = 16...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static Long maximizeVolume(Long 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 BufferedRea...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "maximizeVolume(self, S)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n S = int(input())\n\n ob = Solution()\n print(ob.ma...
eJyFUkEKwjAQ9NCHlJyLJGmSpr5EsOJBc/ASe2hBFEX/oP81XVvEw2yXQgvd2dmZnUf2fmYLqvUlfWyu4hjbvhOrXKgmlqLIRTi3Yd+Fw+7Ud79f9yaKW5H/9xvQr0G/Bf0G9FdoH0SgJECUDiEU2slDDipEVMnxcbW2tUa8NRUzZIR/p3FDkKk0xHhlvFHDC5msNBjgICIlBUVFcqsym9pBLqeVnGcyiojTuSZ69mzkEby5npHtrJNwg4TjfIY4GH8PISQY4aA8cmcymM3TEEdDt+LlzmndvpYfJhRhGQ==
705,653
Shortest Uncommon Subsequence
Given two strings S and T, find length of the shortest subsequence in S which is not a subsequence in T. If no such subsequence is possible, return -1. A subsequence is a sequence that appears in the same relative order, but not necessarily contiguous. A string of length n has 2**ndifferent possible subsequences. Examp...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int shortestUnSub(String S, String T)" ], "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 B...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "shortestUnSub(self, S, T)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n S, T = map(str, input().split())\n\n ob = Solution()\n ...
eJztWM1OhDAQ9uBDeGx6Xo0/l41v4G2PJq4xlBYoP22B8rdG40Po+0qMe2G3WSC0IPL1MgkZ+NqZ+WbKx/nX5uLsB48PtfH0CikTmYT3AN5smYVsTBzXoz6wLIRsG2NCHMd1PY9S34crAEkpiC0JfuGZ/HW8rD3ftwy+rYDqdUEYMS7iJJVZXpTVriqLPJNpEgvOojDwqec6BNvIAt19FKxulaR0L6D/E/XqGozdnADGJjAohqurYZ8cFYEgCMMoYoxzIeI4SdJUyizL86Ioy6oaaOvq4t1z1WeBk+z+Q4nNp8JUKXY9XodoLIBMoGMy...
711,154
Merging Details
Bob, a teacherof St. Joseph School given a task by his principalto merge the details of the students where each element details[i] is a list of strings, where the first element details[i][0] is a name of the student, and the rest of the elements are emails representing emails of the student. Two details definitely bel...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1656400098, "func_sign": [ "public List<List<String>> mergeDetails(List<List<String>> details)" ], "initial_code": "// Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\nclass GFG {\n public static void main(St...
{ "class_name": "Solution", "created_at_timestamp": 1656568825, "func_sign": [ "mergeDetails(self, details : List[List[str]]) -> List[List[str]]" ], "initial_code": "# Initial Template for Python 3\n\nfrom typing import List\n\nif __name__ == \"__main__\":\n T = int(input())\n for t in range(T):\n ...
eJztWM1u00AQ5sBDcFzlPKrkdQKIE6WUn557QMRRtEld4ja2KzctLQjEQ8BrceN92Flv4p1ZO7VpItFCVSk7s7Mz3/zYM+tvD3/8evTA/L37qRfDz70kO7tY9J6JXhBlT6Jsd55MYyGjTOHieaqS+c40T4Uhxx/z4nTFi7IX+QRFJ/lklqeOsGY4UqXK0KqkOqzes7g4z/U+4wcydPTszVQxT2KhgU7LpWck4LhLjIHBOCYgK31ypa8Gh92hSHogevHVWTxdxEfj/GJhIzgcGhTgg7csTvv2oC7QIxBD7QaQuBqKeOSKjb0d6y3UebRi...
701,236
Indexes of Subarray Sum
Given an unsorted array arr containing only non-negative integers, your task is to find a continuous subarray (a contiguous sequence of elements) whose sum equals a specified value s. You need to return the 1-based indices of the leftmost and rightmost elements of this subarray. Examples: Input: arr[] = [1,2,3,7,5], s ...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1728923121, "func_sign": [ "static ArrayList<Integer> subarraySum(int[] arr, int target)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass Main {\n public static void main(String args[]) throws IOException {\n BufferedReader ...
{ "class_name": "Solution", "created_at_timestamp": 1728923121, "func_sign": [ "subArraySum(self, arr, target)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n tc = int(input().strip())\n while tc > 0:\n arr = list(map(int, input().strip().split()))\n ...
eJzlVc1OwzAM5sCBx/iU80CO07/wJEgUcYAicSDs0ElICMRDwPtit+zQUZexbhISTdpGiRP7sz87b8cfDydH3XNxJ4PLZ3eflqvWncP5OnkCEwIhI+SEglASKkIkeCJZz8kt4JqnZXPTNrfXj6t2vRl5nV7r5F4WGJ6ZY0ZTk2yVTIZO2aQABI2g8Jx3r451Thd7EfNgb5xL2KWpQTaGytAVY4RXYwWmxkSD0gMoSOOigdHIrAEFG1AhIpanwAjIxNcFSlQQnXKg6GX4AJ/Bi/NkfwlfwUelB8seBgdwBnVrAS4FBjiKlZ0dNtjMDBj+...
701,269
Determinant of a Matrix
Given a square matrix of size n*n. The task is to find the determinant of this matrix. Examples: Input: n = 4 matrix[][] = {{1, 0, 2, -1}, {3, 0, 0, 5}, {2, 1, 4, -3}, {1, 0, 5, 0}} Output: 30 Explanation: Determinant of the given matrix is 30. Input: n = 3 matrix[][] = {{1, 2,...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1618655389, "func_sign": [ "static int determinantOfMatrix(int matrix[][], int n)" ], "initial_code": "import java.io.*;\nimport java.util.*;\nclass GFG\n{\n public static void main(String args[])throws IOException\n {\n Scanner sc = new Sca...
{ "class_name": "Solution", "created_at_timestamp": 1618655389, "func_sign": [ "determinantOfMatrix(self,matrix,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 values = list(map(int, inpu...
eJy1lE1OwzAQhVkgzvHkdY0ytuMfToKEEQvogo3pIpWQEIhDwH0Zm5CqUqY0/MRZ2E7mfTNPY7+evoezk/Zcdjy5elL3ZbMd1AUU5cJvr1ZQ68fN+nZY3908bIfxa5/LSy7qeYX9EJNLhzaEwE4OJBhYOCFQGyHSTsjdWAi3Fa4rv2bAE815QKrdSzIuF00da3yGQ3sE6IgE3q1f2tpVhJGqtEmqs6lzZFVnEd30dQPo1OQTIgM8kyUTpcz7asDOv6PmAoJkRDW35wyJQBbEkwRjYRIswQY4gmPnAnr+L8ETfEAgBIvAtVnEhBQk55zv...
703,177
The Tiny Miny
Given two integers a and n, generate a series by raising a to the power of 1 to n (i.e., a^1, a^2, a^3, ..., a^n). From each result, extract all the digits (including repeating ones), and then form the smallest possible number using all these digits (excluding zeros). Examples: Input: a = 9, n = 4 Output: 1125667899 E...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1616691291, "func_sign": [ "public String tinyMiny(int a, int n)" ], "initial_code": "import java.util.Scanner;\n\n//Position this line where user code will be pasted.\n\npublic class Main {\n public static void main(String[] args) {\n Scanner ...
{ "class_name": "Solution", "created_at_timestamp": 1616691291, "func_sign": [ "tinyMiny(self, a, n)" ], "initial_code": "def main():\n t = int(input())\n for _ in range(t):\n a, n = map(int, input().split())\n solution = Solution()\n print(solution.tinyMiny(a, n))\n prin...
eJzdV7tOxDAQpKDkIyzXJxR7/QpfgoQRBaSgMVfkJCQE4iPgn+j4JXY3yQEi9kVIKXxTnHLn887sjB0nr6fvn2cnjMsPvLh6kvdpu+vlhZAqJt8IKzdCdo/b7rbv7m4edv00qjSAMcZ5H9qYXmKSzxvxezoYAdnpQNOtm52rY3Je4KdFATg6X4PIR25UgwBLcHMVISbTCBOTDgKvfaGs0qTLDWWorrE+fPOUu0bNWlNxBcSWN4/1ci1Dmp0LYWSgQcBfkCFnLOaiMqV9RhUb6Ut2Nss6BE4F/wyKnFSWcsr1ObWkwfl2bAfbszbTmMOM...
700,570
Reverse a string using Stack
You are given a string S, the task is to reverse the string using stack. Examples: Input: S="GeeksforGeeks" Output: skeeGrofskeeG
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1616992603, "func_sign": [ "public String reverse(String S)" ], "initial_code": "/*package whatever //do not write package name here */\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n\tpublic static void main (String[] args) {\n Scanner...
{ "class_name": null, "created_at_timestamp": 1616992603, "func_sign": [ "reverse(S)" ], "initial_code": "# Position this line where user code will be pasted.\nif __name__ == '__main__':\n t = int(input())\n for i in range(t):\n str1 = input()\n print(reverse(str1))\n print(\"~\...
eJy1lNtOwkAURX0wfsdQLwGrxiLlZkxERQRUblVAiqSWsa3oUNopoIjxI/RbfTPWajQGTsEmNPPQpN3nnJm99jzPv74vzDlP5c1+qQ0YjegWZeKI4USS2Ns/SB6mjtKZ7PHJaS5fKJaEs/NypXohXclNfK2o2k3r9o609Y5hUqvb698/iIRZQwzu61imuNloW/S73sN9v9e1qGl09Da5u23daKpyjZvylXRRrZTPz4RSsZDPnZ4cZzPpo9Rh8mB/LyGSJ7vecA39nYsLboX4cCQa2/TtLi4tX66s+gMNdn2nVh8MH7fjogiMIIrx7cfh...
705,016
Fact Digit Sum
A(X) for positive integer Xis thesum of factorials of its digits. For example, A(154) = 1! + 5! + 4!= 145.Given a number N, find the minimum number Xsuch that A(X) = N. You have to returna list of digits (without leading zeros) which represent the number X. Examples: Input: N = 40321 Output: 18 Explanation: A(18)=1!...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "ArrayList<Integer> FactDigit(int N)" ], "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": [ "FactDigit(self, N)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n N = int(input())\n ob = Solution()\n ans = ob.FactDigit...
eJy9U0sKwjAUdKH3KFmL5OVn4kkEKy60CzfVRQuCCB5Cj+POg5kmVRTfi6joLEqhncm8N5N993judQLGJ/8y2bJlua4rNsoY5CXwANbPWLFZF/OqWMxWddX+IISUSjcwZhhgA5zLS7brZ49aQisOhtJyERhRGmEtacLdgHHjF4IKb/kHpSkdpfGBwUpBcJRS8eAG7bmoiKN3duUH6xjZDmWCHM7FaIpLQfkWKMP3hE4oLhZPFlLR3verDebnQKe7DhhbEJ6gSduAFzEhlOposwHzpMi/uVCkc/L2JTKSvsnmD8Ggk/imJqqq7es4m218...
703,250
Merge two strings
Given twostrings S1 and S2 as input, the task is to merge them alternatively i.e. the first character of S1then the first character of S2 and so on till the strings end.NOTE:Add the whole string if other string is empty. Examples: Input: S1 = "Hello" S2 = "Bye" Output: HBeylelo Explanation: The characters of both the...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "String merge(String S1, String S2)" ], "initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*; \nclass GFG{\n public static void main(String args[]) throws IOException { \n BufferedReader...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "merge(self, S1, S2)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n S1, S2 = map(str, input().strip().split())\n ob = Solution()\...
eJy1VdlO20AU7UNf+hcmBcSmlrCDEJA9cfY9oS7Iy3j3zHjs8RKg6ke0/9sEIlRKJkpAnQfLlu+ce+eec+78/Pj76NOHxzX4On75dpcwIKZ+4oxLJAUoThb3+BRgYodLgAgD2QfKLaL+NEx8XgL8MY562OH+AZFkBaicphumZTsQsZE0SZcNxQSW+hQ3Ew67xPNpEEbxiHuCfkb+6xczCRZdicie4gOqBlqoR0Zsjl7vnpk6xaWZuKk0Y9N1HIUB9T3iYgQd2zINXVOBIksil1q+/OtULEVyqATj8n3N04nhmthCNnQcaCMLm65BdE/z...
712,531
Bit Manipulation
Given a 32 bit unsignedinteger num and an integer i. Perform following operations on the number - Examples: Input: 70 3 Output: 1 70 66 Explanation: Bit at the 3rd position from LSB is 1. (1 0 0 0 1 1 0) . The value of the given number after setting the 3rd bit is 70. The value of the given number after clearing 3...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1667394121, "func_sign": [ "static void bitManipulation(int num, int i)" ], "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(Stri...
{ "class_name": "Solution", "created_at_timestamp": 1667541178, "func_sign": [ "bitManipulation(self, num, i)" ], "initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n n, i = list(map(int, input().split()))\n ob = Solutio...
eJy1lclunUUQhVmw4S1+eR2hmrqG7HgLJIxYgBdsTBaOhIRAPAS8L1+b4BiJJo4QV3fo+3d1Deecqv7109+/+OyTx9eXr1l89dPN9/dv3j7cvL5u9PZeLr15dd3c/fjm7tuHu++++eHtw7tNdi65vf/l9v7m51fX30+peaysnmsdTuv13ubdqvzgbbpyhRtn5JjMn0btfj2ZH9wtzy4Ztcvm6K5luSSW15P5wZ3LCp2evOycHUYToR3Xk/nBnalLSZL/ZXUE77kVaa6plX0iI0t1fF2aZyqzIkr8+sv45OtyOzoxjYKBDCg9nJcXne+z...
701,312
Sum of numbers in string
Given a stringstrcontaining alphanumeric characters. The task is to calculate the sum of all the numbers present in the string. Examples: Input: str = 1abc23 Output: 24 Explanation: 1 and 23 are numbers in the string which is added to get the sum as 24. Input: str = geeks4geeks Output: 4 Explanation: 4 is the onl...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1619235809, "func_sign": [ "public static long findSum(String str)" ], "initial_code": "import java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\nclass GFG {\n\tpublic static void main (String[] args) throws IOException{\n\t BufferedReader br=new...
{ "class_name": "Solution", "created_at_timestamp": 1619235809, "func_sign": [ "findSum(self,s)" ], "initial_code": "# Initial Template for Python 3\n\nimport atexit\nimport io\nimport sys\n\n_INPUT_LINES = sys.stdin.read().splitlines()\ninput = iter(_INPUT_LINES).__next__\n_OUTPUT_BUFFER = io.StringIO()\...
eJy1VNtOwkAQ9cEH45t/QPpMzOx91y8xEWOAFiiUUqAoYDR+hP6vA1EsyrClyD5tsrOz55w5e97OP64uztbr9hI3d89BnGazPLipBayRNlmLt0UoI9XRXdOzsevDgCV8KFI5Upkem4mduhwaaVCvBdE8i9p5FD6MZvlXD4dHr3j6Uq9tdwbGhVTaWEfeLVTsbNF0m7WkAWwW1aXVDsnbFHq8BCsGYdQBQJDdXgyASPuDhKYjtCXaLd3Czs2TflQzmYspn7AxZG5kUzPUiRrIvoh5j1UQGXEyAETJARCjAHpSGqguzhqtpOB7APxUUHKh...
701,220
Majority Element
Given an array arr. Find the majority element in the array.If no majority exists, return -1. Examples: Input: arr[] = [3, 1, 3, 3, 2] Output: 3 Explanation: Since, 3 is present more than n/2 times, so it is the majority element. Input: arr[] = [7] Output: 7 Explanation: Since, 7 is single element and present more...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1617273648, "func_sign": [ "static int majorityElement(int arr[])" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass Geeks {\n public static void main(String[] args) throws Excepti...
{ "class_name": "Solution", "created_at_timestamp": 1617273648, "func_sign": [ "majorityElement(self, arr)" ], "initial_code": "# Initial Template for Python 3\n\nimport math\nfrom sys import stdin\n\n\ndef main():\n T = int(input())\n while T > 0:\n A = [int(x) for x in input().strip().split...
eJytVEsOgjAQdWHiDdyZTLpG04Is8CQmYlwoCzfIAhITo/EQel/Lp5YCT6zYRwv086ad6Zv7+DmbjIqynsqPzYUd4yRL2YqYCGNBJdwCXoGqjznEonMS7dPosDtlqV50C2N2dchkCvJCgueFvvsBFubIBJfbalYFTogOsXlkwjXw7gesHmD1qYllHYDNB2zST9SqdZhjyAOco91y0o9oPXoU7RsRc1IwQqQA6BCbcXdQW03qf2EvcegooZb/0LifbcLQ2Pq8qTMjvt0B7heVvgLdGg6GKdrylGj2nwNWHsY6aNSZT1WXdUY1NCRtDtcR...
701,340
Histogram Max Rectangular Area
You are given a histogram represented by an array hist[] of size n, where each element of the array denotes the height of the bars in the histogram. All bars have the same width of 1 unit. Examples: Input: n = 7 hist[] = [6, 2, 5, 4, 5, 1, 6] Output: 12 Explanation: In this example the largest area would be 12 of he...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public static long getMaxArea(long hist[])" ], "initial_code": "import java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass GFG {\n\n public static void main(String[] args) throws IOException {\n BufferedRea...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "getMaxArea(self,histogram)" ], "initial_code": "# Initial Template for Python 3\n\n# by Jinay Shah\n\nif __name__ == '__main__':\n test_cases = int(input())\n for cases in range(test_cases):\n n = int(input())\n ...
eJzFVUtOwzAQZYHENZ6yrlA8HufDSZAIYgFdsAldtBISAnEIWLLjoMxMHLVEndLAgji1XTt+8+br19P3z7MTey4/ZHL1VNz3q826uEARuj6U8kNEQosQECKCTmvEYoFi+bha3q6XdzcPm3U+w6nrX7q+eF5ggkRdTwhgwQogVGgEV0dyoAJ7UEmJYfuObWctafM4lg4wmbZHNQeaPGgzJGUbJtG6VpatGKF2oJILNahPJWIJtp5M5+Fv+r6YSs+8roAoGwm/brPlkSmkhJW3sh7mOoo2lfWTxTyMR8YdnfPOPK97lMjlxBYKJCHK2V2N...
703,922
Sum of Digit is Pallindrome or not
Given a number n.Find if the digit sum(or sum of digits) of n is a Palindrome number or not. Examples: Input: n = 56 Output: 1 Explanation: The digit sum of 56 is 5+6=11.Since, 11 is a palindrome number.Thus, answer is 1. Input: n = 98 Output: 0 Explanation: The digit sum of 98 is 9+8=17. Since 17 is not a palind...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1619177063, "func_sign": [ "int isDigitSumPalindrome(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 BufferedReade...
{ "class_name": "Solution", "created_at_timestamp": 1619177063, "func_sign": [ "isDigitSumPalindrome(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(o...
eJxrYJmaxsIABhHxQEZ0tVJmXkFpiZKVgpJhTJ6hko6CUmpFQWpySWpKfH5pCUKqLiZPqVZHAVW9JYnqDQ1I1gADpLoMBnDoM8BloZGxiamZuQXJ+mCAZA/CIKketDA3MzUxNsJlIS6HmsIAyQEDdi3+0MHjSzISC3kJBmQTEf7EZ6sluZEJ1kx+YiDZrWSnclAomZKZ8gwRQURAZ+wUPQCVGln+
703,931
Simple Interest
Given three integers P,R and T, denoting Principal, Rate of Interest and Time period respectively.Compute the simple Interest. Examples: Input: P=100 R=20 T=2 Output: 40.00 Explanation: The simple interest on 100 at a rate of 20% across 2 time periods is 40. Input: P=999 R=9 T=9 Output: 809.19 Explanation: The si...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "double simpleInterest(int P, int R, int T)" ], "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": [ "simpleInterest(self,A,B,C)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n P, R, T = map(int, input().strip().split(' '))\n ob = ...
eJylVMtKBDEQ9KD/0eTgaQ3p7nQefongiAedg5dxD7MgiOJH6P+aLMvCHLojWOSQQ6pS1Snydflzc3VxxN1129y/u5dlf1jdLTicFgkNgALiduDmt/38tM7Pj6+H9XSGczviQ5iWz2lxHzvY8rHTSQCDwieT3sXb9QGyQhebj8RRoEDS6JXEJ41dS04tOSAZ9KrfHiXlAhSAtfA5huSLxucOaAtREUAKtRafq+agA9oiLULkQJh9JUWBOpoBIM2DIDP5ogmUDsACRc2QjxlGAoYCcypZvAwkkiGBNSaJuotzkU9DtQptNqKV2WwEp2Tx...
703,989
Maximum Sum Problem
A number n can be brokenintothree parts n/2, n/3, and n/4(consider only theinteger part). Each number obtained in this process can be divided further recursively.Find the maximum sum that can be obtained bysumming up the divided partstogether.Note: It is possible that we don't divide the number at all. Examples: Input:...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int maxSum(int n)" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nclass GfG\n{\n public static void main(String args[])\n {\n Scanner sc = new Scanner(System.in);\...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "maxSum(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.maxSum(n))\n...
eJy1VEFOwzAQ5AD/iHyu0Nprrx1egtQgDpADl7SHVKqEQDwCvsaNv3ST0CqtOk6pyiqHKM5kZmdn83H99XNz1df9t97MX81Ls1y15q4wtmqcrxozK0y9XtZPbf38uFi1v6cuVs27nr7Nin2MJYIg6wihHPsgmM0nIQ+wmA+xBeoqI9OSTQhcpighYwx7SU4QuC8MDiJcMgArLTuLZQdKYhF4gpg4UgLQ2BfmLclHQXmIo671K/28qpGN+hCbGad8PNPJbU5VSle5LGTaGuV20COXbHG4aND3d4FW1IJDocdbP0k+7oCZPaHxd5kdbVwu...
702,703
Flip Bits
Given an array A[] consistingof 0’s and 1’s. A flip operation is one in which you turn 1 into0 and a 0 into1. You have to do at most one“Flip” operationof any subarray. Formally, select a range (l, r) in the array A[], such that (0 ≤ l ≤ r < n) holds and flip the elements in this range to get the maximum ones in the fi...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1617649146, "func_sign": [ "public static int maxOnes(int a[], int n)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\nclass GFG {\n\tpublic static void main(String[] args) throws IOExcept...
{ "class_name": "Solution", "created_at_timestamp": 1617649146, "func_sign": [ "maxOnes(self, a, n)" ], "initial_code": "# Initial Template for Python 3\n\ndef main():\n T = int(input())\n while T > 0:\n n = int(input())\n a = [int(x) for x in input().strip().split()]\n ob = Sol...
eJy1VEsOgjAQdWE8R9M1MVMN8XMSEzEulIWbygISE6PxAu7wvra0QBk6mCYCnUKb9s2bN9O+pp9yNqme3Vv97O/8IrMi51vGRSIFKGPAtOnefnnEeHrL0lOeno/XIrcbVol8JpI/IoZQ4kQaDMIIvDWBt6hY1WwA4Tk8SaaakRd6CZqqgRANuEBO3Jl2xYC7DeEubvQVDhztokuspdMnJ5w9dpYgp0P2pw2szsOCuPPAcCxYMMy1mz9fnH3Z8VraCx5RGsTeeqDq0iOVqhoq95S6qoVuaeq+81IoZF5N04cymLRh8BcKECgASXa8YzXS...
703,795
Query and Array
Given an array of integers arr and a query integer k. Find the number Xfromthe arrayso that it can be converted from k toX andF(k, X) is minimum. F(A, B) = Number of bits flipped to change the number A to B. If there is more than one value in arrsuch that F(k, X) is minimum print the smallest value of X for which F(k, ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1617640199, "func_sign": [ "int findX(int[] arr, int k)" ], "initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass GFG {\n public stat...
{ "class_name": "Solution", "created_at_timestamp": 1617640199, "func_sign": [ "findX(self, arr, k)" ], "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 k = int(input())\n ...
eJzFVk2LFEEM9eDFPyFhwNsilY+qpPwlgi0edA5e2j3MgiCKP0L/r6lKz6y7mHXZcTGHetN0d1765SXM96c/Xzx7MuP1c//x5svu43p5ddi9gh0uK5YZ0GcAEktt0KowIdgM4BmgM6DOAJyxrPHi7gJ2+8+X+/eH/Yd3n64OG0HcXNZvy7r7egG3qcWqNsBCAuQXIKU3MOwE2NgEmLSZF1PZn2IsSkCNUGRZKwmZJbQjY0JKIGCe3nNDE/9eA/IPrkijDvaqkpyUJNykmkABHCABNWATVQMsoG/vl4Q0kifMpmwIqKKNgKXXwdj7EBK5...
703,523
Nine Divisors
Find the count of numbers less than equal to N having exactly 9 divisors. Examples: Input: N = 100 Output: 2 Explanation: The two numbers which have exactly 9 divisors are 36 and 100. Input: N = 1000 Output: 8 Explanation: The numbers are: 36 100 196 225 256 441 484 676
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static long nineDivisors(long N)" ], "initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*;\n//Position this line where user code will be pasted.\nclass GFG\n{\n public static void main(String ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "nineDivisors(self, 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 ob = Solution()\n print(ob.nineDivi...
eJxrYJlaysIABhF5QEZ0tVJmXkFpiZKVgpJhTJ6hko6CUmpFQWpySWpKfH5pCVTKICavLiZPqVZHAVW9EYnqLUlUb4HLQYY4NJga4nKSOQ4d5ka4HGWBQ4ehkaUZLmfhcpehARDg0GRshMszlgYmuBxnboLPJlxWWZriDje8oWeEy2MWoFRgSGo0wTxHyFpc6QISb6YgFijIjSjWT65DYPpI8BPOoDQl0xNU8YURwbg0x5VMgY7A72EzqMbYKXoA3i5huw==
702,068
Closest Three Sum
Given an array, arr of integers, and another number target, find three integers in the array such that their sum is closest to the target. Return the sum of the three integers. Examples: Input: arr[] = [-7, 9, 8, 3, 1, 1], target = 2 Output: 2 Explanation: There is only one triplet present in the array where element...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int threeSumClosest(int[] array, int target)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\npublic class GFG {\n public static void main(String args[]) throws IOExcepti...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "threeSumClosest(self, arr, target)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n\n for _ in range(t):\n A = list(map(int, input().strip().split()))\n ...
eJy1lMFOwzAMhjkgnuNXL1wWFCfx2vEkSBRxgB24lB02CQmBeAh4X2xnwBD1KCC8LW0W5/Mfx8nT4cvx0YHZGeTl/L65GVabdXOKhvqBIogRUkRGiw4hI/ZD4maGZnm3Wl6tl9eXt5v1dkbifnjsh+Zhhs+cwBGhyC9HowUBCzpCyREywsL1sBQdLEXVpxTFsvGVpjiZUzg6xMIeUpSpQRTrw0gaxf6ViA7QVYhff/ohO8HyN9qrZE2IPFprqXbCzmo0a7GmrCZN16fjTlQ2h9HACzUEbTt8BLI4MFX6WrfpbYfUA3MVqJ1OmoUl2Jbg...
704,662
Bit Difference
We define f(X, Y)as number of different corresponding bits in binary representation of X and Y. For example, f (2, 7)= 2, since binary representation of 2 and 7 are 010and 111, respectively. The first and the third bit differ, sof (2, 7)= 2. Examples: Input: N = 2 A = {2, 4} Output: 4 Explanation: We return f(2, 2)...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int countBits(int N, long A[])" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG{\n public static void main(String args[])throws IOException\n {\n Buffe...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "countBits(self, N, A)" ], "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 = input().split()\n for it in r...
eJy9VcuOUzEMZcGKr7DugtWA4tiJHb4EiSIW0AWbMouOhIRAfAT8L45vcjtCuEDpYKtu1Id9bJ9z8/Xx92dPHrm9fGqHV5+W94fbu+PyAhbcHTDtDgUzYMoMObECp1ZBsdlnlZSBslSFWgpVQMIkGXLNyLzcwLL/eLt/e9y/e/Ph7jiTqqX8sjssn2/gp1rFXpm4VPAo4NFK9tjAYwKPCB4zeCTwyICYMxH0wAbNQinQQ63Qgwj0oBqAy0k1QJcNdlsNdDWQ1Synm5Vws4puBsDN8LgZPDebprsN1B0oudts3aEkd6jJHSS5gyZ369Yd...
703,364
Merging two unsorted arrays in sorted order
Given two different arrays arr1[] and arr2[], the task is to merge the two unsorted arrays and return a sorted array. Examples: Input: arr1[] = [10, 5, 15] , arr2[] = [20, 3, 2] Output: [2, 3, 5, 10, 15, 20] Explanation: After merging both the array's and sorting it with get the desired output. Input: arr1[] = [1, 10...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1724152579, "func_sign": [ "public void sortedMerge(int[] arr1, int[] arr2, int[] res)" ], "initial_code": "import java.util.*;\n\n//Position this line where user code will be pasted.\npublic class Main {\n public static void main(String[] args) {\n ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "sortedMerge(self, arr1,arr2,res)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input().strip())\n for _ in range(t):\n # First line contains the sizes of the arrays\n...
eJztWsGOG7kVzCEfQsx5GTTJRza1XxIgDnJIfMjF2YMXCBAk2I/Y/G9eVVGtJ+zMeGxv7JFXWuOtRmKpyXpVxe6Wfvr9f7+fv+Pjj82f/OlfD39/98OP7x++Tw/lzbuy+SOd/IEyUXaUgdJRDKWhVJSCAsQEYgIxgZhATCAmEBOICcQEYgKxA7EDsQOxA7EDsQOxA7EDsQOxAzGAGEAMIAYQA4gBxABiADGAGEB0IDoQHYgORAeiA9GB6EB0IPrmBKSaWrLU00h7cmAqWyollZpKS8VS6amMVPZUZiqnVLdUHVNTbalaqj3Vkeqe6kz1...
704,488
Last two digit Fibonacci
Given a number N. Find the last two digits of the Nth fibonacci number.Note: If the last two digits are 02, return 2. Examples: Input: N = 13 Output: 33 Explanation: The 13th Fibonacci number is 233. So last two digits are 3 and 3. Input: N = 255 Output: 70 Explanation: The 255th fibonacci number is 875715953430...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "int fibonacciDigits(long N)" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader rea...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "fibonacciDigits(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 ans = ob.fibo...
eJxrYJnqzcoABhEuQEZ0tVJmXkFpiZKVgpJhTJ6hAQZQ0lFQSq0oSE0uSU2Jzy8tgSo2N43Jq4vJU6rVUUA1wpRYE4xwmWCJAXCZYIbDBGNi3WBggMsEDIArHCxwmIARlKQGpDmF+g2NjE1MzcwtLA1gLBwmmJngiggLczNTE2MjQwMYC1cwWuJKDBgAly9wRQSlSQElOWJNGjjTJ87URXnioEQvRcGBnqhITlXG0HDEyOa4koYh8RGDLBQTQ1bcUJhaDIhPHvCiI3aKHgBhJITJ
706,079
Lucy's Neighbours
Lucy lives in house number x. She has a list of n house numbers in the society. Distance between houses can be determined by studying the difference between house numbers. Help her find out k closest neighbors. Return the list of house numbers in sorted order.Note: If two houses are equidistant and Lucy has to pick onl...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public ArrayList<Integer> Kclosest(int arr[], int n, int x, int k)" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*; \nimport java.lang.*;\n//Position this line where user code will be ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "Kclosest(self, arr, n, x, k)" ], "initial_code": "# Initial Template for Python 3\n\nimport heapq\n# Position this line where user code will be pasted.\nif __name__ == \"__main__\":\n t = int(input())\n for _ in range(t)...
eJy9VMFOwzAM5YD4DqvnBSVu0zR8CRJFHGAHLmWHTZqEQHwE/B43/oNnZ63EmEfhQKV6mfP8bL84fTl9+zg70efyHYurx+p+WG3W1QVVoR86ip5iPwTvqckUA9WeElyRmkjZVwuqltvV8na9vLt52Kx3kQBhuwQA2g/P/VA9LegrefDkhLjtBxdlLY4sCxYDEtfhbeVPI1tR8NHIuYsqpLGgc6Gw8jMx0ieskJ7l5Ugh4UUgg4lBxKgjgCSgjgDS0FkVaKQgu8IgaGUIdgkoUhIHDw1qFONYDYs/iREVWLpn0YGTmKwQMdItdwpRsNKZ...
712,246
Prefix to Postfix Conversion
You are given a string that represents the prefix form of a valid mathematical expression. Convert it to its postfix form. Examples: Input: *-A/BC-/AKL Output: ABC/-AK/L-* Explanation: The above output is its valid postfix form.
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1666246655, "func_sign": [ "static String preToPost(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": 1667285700, "func_sign": [ "preToPost(self, pre_exp)" ], "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 for _ in range(t):\n prefix = ...
eJzNVrFOwzAQZWDhL6qMdzUW0InNsZMgtextMWaADiyhQyshIRAfAf/L2UnapIodSKuKDpVdOe+9e+986efp9+3ZiftMU1rcvUXP+XK9iq4H0ZXOAUXMpNI541OYzXE80TmigFiqaDiIFq/LxeNq8fTwsl6VD4kYpWKg8w+dT2dz4OMJMrcTsQRU6NbR+3BQY7okJhETNH1LLzCUMCBbQUZWpUNQmKSEyASnNbdrbGzQrkElqZ9Koj27Vc6Zgvo6STlu9qgSaJV0QZIY2iMqCfjFVMJZ2/M2AYZcVMptHODicBmEUDlVwEhlpZpSAajl...
702,869
Pair with greatest product in array
Given an array arr[] of positive integers, the task is to find the largest element in the array that can be expressed as the product of two elements from the array. The two elements forming the product must be at different indices. Examples: Input: arr[] = [10, 3, 5, 30, 35] Output: 30 Explanation: 30 is the product ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int findGreatest(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.parse...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "findGreatest(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 arr = list(map(int, input().strip().spli...
eJydU0sOgjAQdcFBJl2j6UCp4ElMxLhQFm7QBSQmxsRD6KHceSTHIvihI5RpF9NMX+fNy+vZu969kYn5jZLFUWzzfVmIGQhMcxQ+iOywz9ZFtlntyuJVGlNNnHz4vh1ACBoSwJiBYWyDoQTakVOrpIpwCghNzrzQ1O2cFaCGINJEIlCgZEKZDmPFzfCs2ceoA4wQDF4zWBqkEsJsyXWX0oqH1uIesIowUPsu5e14fjrGVqRIbSw6hm5s29I4aoNubI0NPuzw1wydlMmaQ0j/krBaDNNU5uj8y98yDqDE/ap+WlbdsYeky8vkAVcFW5Q=
705,287
Decode the string
An encoded string (s) is given, and the task is to decode it. The encoding pattern is that the occurrence of the string is given at the starting of the string and each string is enclosed by square brackets.Note:The occurance of a singlestring isless than 1000. Examples: Input: s = 1[b] Output: b Explanation: 'b' is ...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static String decodedString(String s)" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG{\n public static void main(String args[])throws IOException\n {\n Buffe...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "decodedString(self, s)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n s = input()\n\n ob = Solution()\n print(ob.decodedS...
eJylk0FOwzAQRVnAPSKvK1Q7ZcOOXY+ANLFQYjsSizhplUp2UCsOAfdl0oRKrfgJhRknjuTM0/f3+P32c313c4znJ/6gN/Hqm10rHhMhMy+XlGuxSIQLjTOtsy/1rh2X81Nk/pB5sV8k58WKUioUGa0RojDmYgCUpMBSou4QKcRTdJCRUl4YvaIQoSL+YRghDglgD7RZ0RZiNluOn14AtyRXNW1EOLijThLeS4fEK+q9sE4rKvHhWNdnWX7PAMamakkFswwzsbE5m2qt7R+4HUWVIpZXayyr8nXNY5wgKssmveFl5A67OlE35Wh6raUz...
703,324
Sub-Array Pairs
Given an array arr[], your task is to count the total number of distinct pairs that can be formed from all its contiguous subarrays, where each subarray contains only distinct elements. A "pair" refers to a combination of two elements (i, j) from the subarray, where i and j are distinct. Examples: Input: arr[] = [1, 4,...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "int countPairs(int[] arr)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\npublic class GFG {\n\n public static void main(String[] args) throws Exception {\n BufferedRead...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "countPairs(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()...
eJydksFKw0AURV3of1xmXWReJtNk6o8IRlxoFm5iFykUxOJH6P96Z0Ch2Bs7BhJCyDvcOfe9X37eXF2U67bly92re562u9lt4GyYDA0CWkSs0aFHgnmYwRpYgLWw6FZw4347Ps7j08PLbv4e9nGYDsPk3lY4ZiZyOvIiuYF8g8fPN0FLXsAyZE1MR1BPVCLsOGJ1Pl8SiVvRWgFjDibLErPGLDKrzDKpU8A6ycqyeCZyjBwjx8ixfHLBapS4RFAs6k48FaxXyWLZhVCkWy7gV8n1NYgJdaATdall+mMxrWoz7Zw8fiGOrLtWQJUERUHl...
704,109
Count binary strings
Given two integers n and k, count the number of binary strings of length n where adjacent 1 appear k times. Since the answer can be huge, print it modulo 10**9+7. Examples: Input: n = 3 , k = 2 Output: 1 Explanation: Possible string is "111". Input: n = 5 , k = 2 Output: 6 Explanation: Possible strings are: "00111...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int countStrings(int n, int k)" ], "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 Scanner(S...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "countStrings(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 = list(map(int, input().strip().split()))\n ob = So...
eJydk01KxEAUhF3MQZqsB3m/3a89iWDEhWbhJs5iBgRRPISexZ1nszMaGMTqhckm0Hxd71VVXjfvn5uz43P50T6unob7eXfYDxdp4HFmSjps0zA97qbb/XR383DYr6dRxvllnIfnbfoFeXIAGXMASigxAUyow3liAZyreBgAtQmiOUtmC7igehI4am7GmFeAGiWBomLVPRig3rJAqpE9l1IFTZwbCzPJqi5EGcVJlBwKV1ItxTpdWOWRvtZCWLqjzVTNI7OgpXtbF4l2Dg0z6gRVS2Gr7UWVZFxJFiGFveo1KzRy5YA5HWkEazWN0srZ...
704,410
Consecutive numbers for sum
Given a number N, find whether N can be expressed as sum of two or more consecutive positive numbers. Examples: Input: N = 10 Output: Yes Explanation: 10 can be expressesd as 1+2+3+4. Input: N = 8 Output: No Explanation: 8 can't be expressesd sum of two or more consecutive numbers. Input: N = 24 Output: Yes Expl...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static String isSumOfConsecutive(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": [ "isSumOfConsecutive(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(o...
eJxrYJmax8IABhHpQEZ0tVJmXkFpiZKVgpJhTJ6xkbmZhZKOglJqRUFqcklqSnx+aQlU2i8/Jq8uJk+pVkcBVZMlCODQFJlajEOXmampsRmpVpkaGZub49KF2y5DAxAgWZuRoYU56ZrMjAxNTEj1mLGBgTHpDjQkPQDJCgWYA0kPDWOoVmNywh8SbXiSJG6tlrB0SV7axJkyCTkWnIfA4UyGo8Gp24gMq83wpQV89oFdSn4GMTMGZmIiLI6dogcAyOhmAA==
700,384
Minimum Swaps to Sort
Given an array of n distinct elements. Find the minimum number of swaps required to sort the array in strictly increasingorder. Examples: Input: nums = {2, 8, 5, 4} Output: 1 Explanation: swap 8 with 4. Input: nums = {10, 19, 6, 3, 5} Output: 2 Explanation: swap 10 with 3 and swap 19 with 5. Constraints: 1 ≤ n≤ ...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1730571324, "func_sign": [ "public int minSwaps(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": 1730571324, "func_sign": [ "minSwaps(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 ...
eJzt2kGOrUcNhmEGLMS6UyL0V7lsV7ESJIIYQAZMQgaJhISQWATskRlb4P38n+5GoTshAYISmhFCvt3n+HFV2ab/9OO//O0nP+r//Pyv/Jdf/OHDbz/97IvPP/zMPoyPPx3XZefY2XbKTtoJO8uO25l2hp3L9rG9bZfttB22l223PW0P25fVsdpWZZVWYbWs3GpaDavL8lhuy7JMy7Bclm45LYflZXEstkVZpEVYLAu3mBbD4rJ1bG1bZSttha1ly21NW8PWZX7Mt3mZp3mYL3M3n+bD/LJ5bG6bZTNths1l021Om8PmZePY2DbKRtoI...
702,821
String Manipulation
Tom is a string freak. He has got sequences of words arr[] to manipulate. If in a sequence, two same words come together then Tom destroys each other. Find the number of words left in the sequence after this pairwise destruction. Examples: Input: arr[] = ["ab", "aa", "aa", "bcd", "ab"] Output: 3 Explanation: After t...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1617822225, "func_sign": [ "static int removeConsecutiveSame(String[] arr)" ], "initial_code": "import java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n BufferedR...
{ "class_name": "Solution", "created_at_timestamp": 1617822225, "func_sign": [ "removeAdj(self,arr)" ], "initial_code": "if __name__ == '__main__':\n tcs = int(input())\n\n for _ in range(tcs):\n # n=int(input())\n arr = [x for x in input().split()]\n ob = Solution()\n pr...
eJylVNtOwzAM5QGJ37D6PCG6GxJfgsQQSlt3rQhJSVO2gkB8BPwvXi903XBptFpJ3Dg5iY/tfJ5/Jxdn1XcrSLl781KVFda7Ac9fKZFlEiEQiqQdtBFqjVCb9vv+smpupbwJeLjNMLQYPejCNtjTlfog4/sEDg6EAEKIAEki0gIQLMYVgxEKC5FeV22nx2me1F2QmqjqnDHJH06csQqVPhcIWiHYjQabGESIdWHoki8IjfkvE21hT/M5Sg2Sz5IQ1wSmoEQp9ab5qeZpAYt6zYAmusgRnvb6embHt2ka6c7cbKGEV5IS9jTeZwYl1toG...
704,753
The Modulo Task
Given an integer N. FInd an integer K for which N%K is the largest ( 1 <= K < N). Examples: Input: N = 3 Output: 2 Explanation: 3%1 = 0 3%2 = 1 So, the modulo is highest for 2. Input: N = 4 Output: 3 Explanation: 4%1 = 0 4%2 = 0 4%3 = 1 So, the modulo is highest for 3. Constraints: 1 <= N <= 10**18
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static Long modTask(Long N)" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader rea...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "modTask(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.modTask(N...
eJxrYJn6iYUBDCJeAxnR1UqZeQWlJUpWCkqGMXlApKSjoJRaUZCaXJKaEp9fWoKQrANK1uoooOowwqnDCIcOQwOcWsxwagEDnPpMQbK4XAjVTEg7bgOMSfaiCU4dxrgcaYpTiwUuLWY4tVji0mJOuhZgsBnm4UsZOCPNFBJ2ODWa49YZk0dyaICToiEk8AnGOM60gpTWqGeiOSgISdYIDngUN0HNwuk0iBBOSVLjD+5y0ksFQ+xhaUC5o2A6UYwnpliInaIHAHskjO8=
713,543
Max Sum without Adjacents
Given an array Arrof size Ncontainingpositive integers. Find the maximum sum of a subsequence such that no two numbers in the sequence should be adjacent in the array. Examples: Input: N = 6 Arr[] = {5, 5, 10, 100, 10, 5} Output: 110 Explanation: If you take indices 0, 3 and 5, then Arr[0]+Arr[3]+Arr[5] = 5+100+5 = ...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1673867219, "func_sign": [ "int findMaxSum(int arr[], int n)" ], "initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.io.*;\n\npublic class Main {\n\n public static void main(String[] args) throws Exception {\n Buffe...
{ "class_name": "Solution", "created_at_timestamp": 1673867219, "func_sign": [ "findMaxSum(self,arr, n)" ], "initial_code": "# Initial Template for Python 3\n\n\nif __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n n = int(input())\n arr = list(map(int, input().strip().spli...
eJztlsFOwzAMhjlw5R2inicUx0la8yRIDHGAHbiUHTYJCYF4CHgcbjwYzt92gGi6jQ0kxirN29R+v+3YSf14+Px6dIDr9EV/nN0V1/V0PitOTEHjmqx+jDNsvAkmmtJURgzZYmSKye10cjmbXF3czGctwfr4w7gu7kemR8cqWqlEVCmvks7Q2johxUPWKiyiGlKplJSqKFGFJai+eFNlhGMpGWWnLoPKaJRJXr9W/pfx5V0ui4DVSEkkw8n4ZEIyMZkymSoZsfABC4YAESgCRuAIIIEkoCSdD7WNP7AOrAPrwDqwDqwD66QLTS1YboIF...
704,708
Final Destination
Consider a 2d plane and a Robot which is located at (0,0) whocan move only one unit step at a timein any direction i.e. if its initial position is (x,y), he can go to positions (x + 1, y), (x - 1, y),(x, y + 1) or (x, y - 1). Now Given three integers a,b (denoting the final position where the robot has to reach), and x...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int canReach(Long a, Long b, Long x)" ], "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": [ "canReach(self, a, b, x)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n a, b, x = map(int, input().split())\n\n ob = Solution()\n...
eJxrYJkqxsoABhH8QEZ0tVJmXkFpiZKVgpJhTJ4lDCjoIpiGMJaFko6CUmpFQWpySWpKfH5pCUJjXUyeUq2OAqppSGZgMc0Sh2kGOEwzUDBQMCLRBYYGMKCAxDSCM0n1EJIhutgMNCTRT6ZwIxAsQ3IN0zWCGaJgbophGql+RRiBZC7ZbkN4TxeLT0l1G1aPmpJjGMJvOHShqyeUeolPg0ApBXCaxu8AXCGK3VgD8tK2Lkme0iUYcdiNB2ViYq0gVQMJrsGtLHaKHgCSBGqV
704,020
Minimum insertions to sort an array
Given an array arr of size N, the task is to sort this array in a minimum number of steps where in one step you can remove any array element from its position and insert it in any other position. Examples: Input: N = 7 arr[] = {2, 3, 5, 1, 4, 7, 6} Output: 3 Explanation: We can sort above array in 3 insertion steps...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int minInsertions(int arr[], 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 Scan...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "minInsertions(self,arr, N)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n = int(input())\n Arr = [int(x) for x in input().spli...
eJytlMFKw0AQhj2Iz/GTc5FMNtnt+iSCFQ+ag5fYQwoFEXwIfV/nn02ltVlKEgMLIWG++Wf+mf28/g43V/bcl/ry8F68dttdX9yhkE0nJQ8EERXWcAio4dFsumKFot1v2+e+fXl62/VDDP98rPCHol8bCyarhjhIBRElRaWKsvVjHkoV59Sq5IFEiDKU7ZVxgtds5Acq1gxO80g+SRyVXvEYzBk7IZnIM6mys0Q/BlyzFV7jUt0OdTa+HhVERzSsMUM8BklhuiOsgSVVLM1aVrPOhkAaoxKz0JDrVYS13Tp2YFKs5pnYKNqrBFBgUAKL...
710,295
Minimize Cash Flow
Given a number of friends who have to give or take some amount of money from one another. Design an algorithm by which the total cash flow among all the friends is minimized. Examples: Input: N=3 transaction [][]={{0,100,0}, {0,0,100}, {100,0,0}} Output: transaction [][]={{0,0,0},{0,0,0},{0,0,0}} Explanation: Since...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1711443669, "func_sign": [ "public int[][] minCashFlow(int[][] transaction, int n)" ], "initial_code": "import java.util.*;\n\npublic class GFG {\n\n public static List<Integer> balance(int[][] v, int n) {\n List<Integer> bal = new ArrayList<>(...
{ "class_name": "Solution", "created_at_timestamp": 1711531255, "func_sign": [ "minCashFlow(self, transaction: List[List[int]], n: int) -> List[List[int]]" ], "initial_code": "# Initial Template for Python 3\n\ndef balance(v, n):\n bal = [0] * n\n for i in range(n):\n for j in range(n):\n ...
eJytVctuwjAQ5FCJ37B8Rmhjx4D4EqSm4kBz6CXlECQkBOIj6A/11r+q7dhk7XilGOAROYlndmaWLNe3n7/pxL42v3rxfuJfzf7Q8jXjRdXoD/AZ4/VxX+/a+nP7fWjdXaiaS9Xw84yFEKEhDOwhEyl1PQCN6+Dd2hLZdT5bz4F584WVBqag+3oOy+3XqATJXhDs6k4SUGL7WHsYzwP1Fg7NBETMEqJCZSTBBIBPF+Z0Cf0FSktJaCnARxu+73V6l8MYPEzFsnGcA/2JOAOAbkhUchT/wIPfHt0gAlJEQCtDIxCFxJYEbUfiTg06jS6G...
703,388
Rotating an Array
Given an array arr[]. The task is to rotate the array by d elements where d≤ arr.size. Examples: Input: arr[] = [-1, -2, -3, 4, 5, 6, 7], d = 2 Output: [-3, 4, 5, 6, 7, -1, -2] Explanation: Rotate by 1: [-2, -3, 4, 5, 6, 7, -1] Rotate by 2: [-3, 4, 5, 6, 7, -1, -2] Input: arr[] = [1, 3, 4, 2], d = 3 Output: [2, 1, ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1619001057, "func_sign": [ "void leftRotate(int arr[], int d)" ], "initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass Main {\n public static void main(String args[]) throws IOException {\...
{ "class_name": "Solution", "created_at_timestamp": 1619001057, "func_sign": [ "leftRotate(self, arr, d)" ], "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 d = int(inpu...
eJztV02u1DAMZsGeK1hdv6A6aRObkyAxiAXMgk15i3kSEgJxCDgLO86GnUydQWo6v0/iSXjGY6tNvi9pnC+d789//n7xLNvrX5K8+dJ9nO4fdt0r6HAzcTagbJCyQcwGYzYYskHIBj4bYDbowSE4Dy6AG8CN4CK4BI7AsYB3d9BtP99v3++2H959etjtedd6wZUj2kzfNlP39Q7+nif6MIwxEQsFpTgOwevosZ9NhlTzctvlsJmGxjRaPeA4WWuUcsuLB/FBUcWjeBInce4LikxWf7QpalvUxqitUZujtkftgFwQe8EeG9NodYHrR9OY...
713,145
Make array elements unique
Given an array arr[ ]of Nelements, your task is to find the minimum number of increment operations required to make all the elements of the array unique. ie- no value in the array should occur more than once. In an operation a value can be incremented by 1 only. Examples: Input: N = 3 arr[] = {1, 2, 2} Output: 1 Expl...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1730201483, "func_sign": [ "public int minIncrements(int[] arr)" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException...
{ "class_name": "Solution", "created_at_timestamp": 1730201483, "func_sign": [ "minIncrements(self, arr)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n while T > 0:\n arr = [int(i) for i in input().split()]\n ob = Solution()\n ...
eJy1U81KxEAM9iD4GmHOizTzX1/CmwiueNAevNQ9dEEQwYfQ93WabdOuZnYd2U7SzgdtMpnk+z7Ov24uzmjdXidw96ae2822U1egcN1iBfjb1ApU87ppHrvm6eFl2w3/W79u1fsK9lM46JNMngnGSgqOKWBcUI+LUWQUGHlGjpFlZDLHi6d7cJNlArUYGVKbdDKTzIItujO6/WA63icLySLETDInJtN9y3cP9Q36niUP5J7ckVtyQ67Jc3OOKJatJaocoIsPUpoaUBvrfIhzVMfgnTUaGVUjQv6KkVFg5BnlJijfhojPzdu9hve48T6B...
701,212
Stock buy and sell
The cost of stock on each day is given in an array A[] of size N. Find all the segments of days on which you buy and sell the stock such that the sum of difference between sell and buy prices is maximized. Each segment consists of indexes of two elements, first is index of day on which you buy stock and second is index...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1617701723, "func_sign": [ "ArrayList<ArrayList<Integer> > stockBuySell(int A[], int n)" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\npublic class GFG {\n public static void main (String[] args) throws I...
{ "class_name": "Solution", "created_at_timestamp": 1617701723, "func_sign": [ "stockBuySell(self, A, n)" ], "initial_code": "# Initial template for Python\ndef check(ans, A, p):\n c = 0\n for i in range(len(ans)):\n c += A[ans[i][1]] - A[ans[i][0]]\n if (c == p):\n return 1\n el...
eJylVNtKxDAQ9UH/45DnRXJpmqwfIT4KVnzQCn1pi3RBEJf9CP1fJzOIiGbbZtPLCaRzOjlzJofzz/HijMdtR5O7N9X1425SV1Cm6W3TG1i1gWpfx/Zxap8eht30s75vevW+wZ8gC5MJuh5w8zI8d1Mm2Oj0SweLit4eNWFEWJlCnYg0/nkK0wqJEFbDaVQaXqPWCDm2XFrEEjjSM4tjRlOaU+Ti8OVIpQp+ZTqsteaBLQ+BKBAEagEvUAk4AStwarE9bSFQqbc0I5njyn14utku5bb71tIUi/nLcmaJ5467JIpNZl1yhCU5tj7RsqmZ...
704,890
Form a number divisible by 3 using array digits
You will be given an array arr of integers of length N. You can construct an integer from two integers by treating the integers as strings, and then concatenating them. For example, 19 and 4 can be used to construct 194 and 419. Examples: Input: N = 3 arr = {40, 50, 90} Output: 1 Explanation: One such number is 4050...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1619345426, "func_sign": [ "static int isPossible(int N, int arr[])" ], "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 IOExcep...
{ "class_name": "Solution", "created_at_timestamp": 1619345426, "func_sign": [ "isPossible(self, N, arr)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n arr = input().split()\n for i ...
eJytVLFOwzAUZEB8xylzhZ7t2I75EiSCGCADS+iQSkgIxMrGAP/LvbRUBdVV3PQukbz4yXf33ns///68OBtx/cHDzUv12C9XQ3WFyrS9b3tjXe0RYpMEtg6NwDgfE1L0zlQLVN3zsrsfuoe7p9WwuSlt/9b21esCf8vVbZ8UaBSICgRFppDJFHL8EJAKrwXKUcAq4BSoFfCKo95iRH8SVkg4IVELCS8kgpCIQqIREklIGOE1KfQwrjVgqwDb94/PH10trGmZSxODr+FsLtOcfG0RIVQ+ofoJNYBQBwhfHu/YdhTDtjOsyXNsCqskfmCX...
705,233
Coverage of all Zeros in a Binary Matrix
Given a binary matrix contains 0s and 1s only, we need to find the sum of coverage of all zeros of the matrix where coverage for a particular 0 is defined as a total number of ones around a zero in immediate left, right, up and bottom directions. Examples: Input: matrix = [[0, 1, 0], [0, 1, 1], [0, 0, 0]] Output: 6 ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int findCoverage(int[][] matrix)" ], "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 IOExcep...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "findCoverage(self, matrix)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n, m = input().split()\n n = int(n)\n m = int(m...
eJxrYJm6gpMBDCIWAhnR1UqZeQWlJUpWCkqGMXmGCkDCICZPSUdBKbWiIDW5JDUlPr+0BKoCKFMHlKzVUUDXZgrUpgCFJGs3hdqKjEg0wljBGOx6BbBrDCAUmIfDIBOcBplAtYI8AjYK7DoF/MZZ4DDOBOQuAwx3GcB5OMwzNMIV1EBdBjAXokCIkajQEO4FOEQShKtCFYSqIqgSi5lYbMfqTiyCOALCnEBAoNsJTn9DWpDkzGOKFHUo2ZCgKA6rjHBlDjMFM5TYQ450pGSBnYMtTZDoBFCQ4dBA3YABSZiRGjq0SZFDLUkaYNQHxBSD...
702,808
Equal Sum and Product
Given an array of integers arr of some size, return the count of contiguous subarrays for which the sum and product of the elements are equal. Examples: Input: arr[] = [1, 2, 3, 4, 5] Output: 6 Explanation: The 6 subarrays with equal sum and product are: [1], [2], [3], [4], [5], [1, 2, 3]. Input: arr[] = [2, 2, 2] Out...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int countSubarrays(int[] arr)" ], "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);\n ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "countSubarrays(self, arr)" ], "initial_code": "def main():\n t = int(input())\n for _ in range(t):\n arr = list(map(int, input().split()))\n solution = Solution()\n print(solution.countSubarrays(arr)...
eJzNlEtOxDAMhlkgzmFlPUJx0jTNnASJIhbQBZsyi46EhEBzCLghOy6B7bSIx7goZZCo+0ir9utv53d2x8+vJ0eynb3Q4Pze3PSb7WDWYLDt0cK4SzgOswLT3W26q6G7vrzdDtPbru0f2948rOALA/z4aUXXmu4coAapNIi1FlJKIAPGeR7SQbqsqskquApysKqcWsihgYICitBAkgIRhFikirIMgDVgBGyKiyXpFZxKM5+m0VNwBTjrmiICp8LJ5HQ0sEMFnOjjSKBAUD+W1clPguBznUqpJGUPeM9DDay78s9DkRTmpuY9/P/QNONv...
702,843
Balanced Array
Given an array arr of even size, the task is to find a minimum value that can be added to an element so that the array becomes balanced. An array is balanced if the sum of the left half of the array elements is equal to the sum of the right half. Examples: Input: arr = [1, 5, 3, 2] Output: 1 Explanation: Sum of firs...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1617876129, "func_sign": [ "public int minValueToBalance(List<Integer> arr)" ], "initial_code": "// Initial Template for Java\n\nimport java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(Sy...
{ "class_name": "Solution", "created_at_timestamp": 1617876129, "func_sign": [ "min_value_to_balance(self, arr)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input().strip())\n for _ in range(t):\n arr = list(map(int, input().strip().split()))\...
eJytVU1Lw0AQ9SD4Jzw84rVIdnf2y18iWPGgPXiJPaRQEMUfof/XmUkQUWdLia/MayE77zUzk8nb6cfF2Yni+px/3Dx3j8N2N3ZX6Nx6cL0Aza9uhW6z327ux83D3dNunLOrYD28rofuZYUfsvAIIEQkZBRUFhM9+L435IILltiUh8BBHJEjcWSOwlHn/2oIez5vK6u0aqu4qqu86quBOszlaHiYJj5QhFCCUIZQgVCFEFsxOQh5w8HlFCkZFtoKtPlbSwyLyMey1YQoAAkQBPACOMFkYciadcGvT98ocWvcauHqQIggFCDkIeQgxB1m...
702,785
Print Elements of Array
Given an array arr, print all its elements space-separated. Examples: Input: arr[] = [1, 2, 3, 4, 5] Output: 1 2 3 45 Input: arr[] = [2, 3, 5, 5] Output: 2 3 5 5 Constraints: 1 <= arr.size <= 10**6 1 <= arr[i] <= 10**8
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "void printArray(int arr[])" ], "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": 1615292571, "func_sign": [ "printArray(self, arr)" ], "initial_code": "# Initial Template for Python 3\n\n# Driver code\nif __name__ == \"__main__\":\n tc = int(input())\n while tc > 0:\n arr = list(map(int, input().strip().split()))\n ...
eJzdV8FOwzAM5cCZb3jqeUJ1kiYpX4JEEQfYgUvZYZMmIRBfwIn9L06zoU1b3K7dVDR3nqfKfrGTl8T7ul6tbq4auf/mHw/v2Ws9W8yzO2RU1ZRHqepsgmy6nE2f59OXp7fFfOOzdkBVf7LTxwS7AOVasHHMUXpnC6NVElOISQ1DSpsC1vkyR/CjGAEKAhUEOghMEBRBYIOkS+uPmUwTHAJ2hYWDRyiR8UAKpEEGxPAW5EAeVEIJE380VDIpnl/FqlkNa8FqWR2rD3PPSi0c6AQgJBAXOa568+2jcdHYaIpoTDQ6GhUNtVF0ILzIvECS...
701,691
Lucky Numbers
Lucky numbers are subset of integers. Rather than going into much theory, let us see the process of arriving at lucky numbers,Take the set of integers1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,……First, delete every second number, we get following reduced set.1, 3, 5, 7, 9, 11, 13, 15, 17, 19,…………...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1617190267, "func_sign": [ "public static boolean isLucky(int n)" ], "initial_code": "//Initial Template for Java\nimport java.util.*;\nimport java.io.*;\nimport java.lang.*;\n\nclass Driver\n{\n public static void main(String args[])throws IOExceptio...
{ "class_name": "Solution", "created_at_timestamp": 1617190267, "func_sign": [ "isLucky(self, n)" ], "initial_code": "# Initial Template for Python 3\n\n# contributed by RavinderSinghPB\n\nif __name__ == '__main__':\n t = int(input())\n\n for tcs in range(t):\n n = int(input())\n obj =...
eJxrYJkaxMIABhHeQEZ0tVJmXkFpiZKVgpJhTJ4lEBgq6SgopVYUpCaXpKbE55eWQKUNYvLqYvKUanUUMPRYWJKox9DI2MSURD2mBkBAqj1k6DExJV2PORl6LECARD3GIECiHjMQIN1tMBeS7EZgeiA1lqAJArdOQ9w6wdFlSbpWiBfBuhFeJcv54AAmNfYtDckOJtQQI9XfZuSkByKSd+wUPQBXPFZR
704,039
Minimum cost to fill given weight in a bag
Given an array cost[] of positive integers of size n and an integer w, where cost[i] represents the cost of an i kg packet of oranges, the task is to find the minimum cost to buy exactly w kg of oranges. The cost array has a 1-based indexing. If buying exactly w kg of oranges is impossible, then return -1.Note:1. cost[...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1619000327, "func_sign": [ "public static int minimumCost(int n, int w, int[] cost)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass IntArray {\n public static int[] input(BufferedReader br, int n) throws IOException {\n Str...
{ "class_name": "Solution", "created_at_timestamp": 1619000327, "func_sign": [ "minimumCost(self, n : int, w : int, cost : 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().spli...
eJzVlU1Ow0AMhVkgcQ0r6wbF9kwy4SSVKOoCumATWLQSEgJxCLgvzzNpKwSmacWGqhNNfuab52c7eTv/WF6c5d98jsn1c3U/PG7W1RVVvBi4WQyCUTNxQ4ESYdaRNIQLQhyrGVWrp8fV7Xp1t3zYrLdLseZ1MVQvM/oKTIUJSjSUgAiwUueAeofDEcIwGIAOwjILhxZcE2ZMnJpudtCdhxYM6IyFJyD1JWwGzWbJIUaHaA5GjADDTFomp1Ffa2AFuDfhuKBmr9hmtSc9edKxiVrKKBts1uxsoHAkzOwNjUGLYC0ZB7O1UysGKQab9GBB...
703,681
Circle of strings
Given an array arr of lowercase strings, determine if the strings can be chained together to form a circle.A string X can be chained together with another string Y if the last character of X is the same as the first character of Y. If every string of the array can be chained with exactly two strings of the array(one wi...
geeksforgeeks
Hard
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public int isCircle(String arr[])" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "isCircle(self, arr)" ], "initial_code": "# Initial Template for Python 3\n\nimport sys\n\nsys.setrecursionlimit(10**6)\n\nif __name__ == '__main__':\n t = int(input())\n\n for _ in range(t):\n N = int(input())\n ...
eJxrYJnKw8oABhGsQEZ0tVJmXkFpiZKVgpJhTB4QJcbkKekoKKVWFKQml6SmxOeXliDk64CStToKqJqMgJqSFJJI12gM1KhAnlYTiJ3JCskpCimUaU9MxqndAId2U2TbUxVS0xTSSHeDGTTYwIYkgw1JJdklZpguSVdIzyDZHHOgORUKFZhGke4vXEZl4DYKl6vA0USiHlCiotTF5HrdWAGWoo2pF24gd1CetkB5jIz0BYqBPFKjAMkniahJIJn0NAA0DJGCSNVMVHkWO0UPAIIWorE=
701,266
Search in a row-column sorted Matrix
Given a matrix of sizen x m, where every row and column is sorted in increasing order, and a number x. Find whether element x is present in the matrix or not. Return a boolean value trueif x is present in the matrix and falseif it is not present.Examples : Examples: Input: matrix[][] = [[3, 30, 38],[36, 43, 60],[40, 5...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1730682380, "func_sign": [ "public boolean searchMatrix(int[][] mat, int x)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n Scanner sc = new Scanner(Syst...
{ "class_name": "Solution", "created_at_timestamp": 1730682380, "func_sign": [ "searchMatrix(self,mat, x)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n import sys\n input = sys.stdin.read\n data = input().split()\n\n t = int(data[0])\n index = 1\n ...
eJztmu1qpEUQhf3hhRTze5Wu7uovr0TYiPgRQZBx0QQEUbwIvV/POW9idtfJRHuzkl3fZQoStt/unqfq1Edmfvvwjy8/+kD/Pn2OH57/fPj2+OL66vCJHfziWPVyC+vmbo5fslUb5tl8XhyLNZvmzXLGsmRezMO8Ww78Piy75WK5WUl4Mh2e2eHypxeXX11dfv3599dXNwd988V3P15eHH+9OB5+eWav3iD0wjZWDD9UHNhtXBxxatKVePB2asVF8Eu955SrH67vO6TphQ1zwk0tktVkLXEzy9VKtahWcTbf/7AyLIbVYW1Yx11KtgCW...
704,041
Shortest path from 1 to n
Consider a directed graph whose vertices are numbered from 1 to n. There is an edge from a vertex i to a vertex j if and only if either j = i + 1 or j = 3 * i. The task is to find the minimum number of edges in a path from vertex 1 to vertex n. Examples: Input: n = 9 Output: 2 Explanation: Many paths are possible fr...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1618657962, "func_sign": [ "public int minStep(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 BufferedReader ...
{ "class_name": "Solution", "created_at_timestamp": 1618657962, "func_sign": [ "minimumStep(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.minimum...
eJydkkEKwjAQRV30ICXrIk3GWutJBEdcaBduYhctFETxEHoxd97GpKSIyh9qZ5WQPuZ15l+j+zOadLV6uMP6pA62amq1jJVmq1NfbFUSq7Ktyl1d7rfHpu6/KNhe3Os5iT+5whfGFgAjXxjLAaYlR0ERMshPC32QnNBmDpAMd0FmJocIoZ/JIDJDSD+3lBk7QrrryaG1DdaCeSql6x0XyBs0YCJRh7r3//MkRcoMn4oYZzSTsJ2vDY0e8a+Vu4zxolA4niifwpKYB69pc5u+AIRtiQE=
712,058
Fibonacci series up to Nth term
You are given an integer n, return the fibonacci series till the nth(0-based indexing) term. Since the terms can become very large return the terms modulo 10**9+7. Examples: Input: n = 5 Output: 0 1 1 2 3 5 Explanation: 0 1 1 2 3 5 is the Fibonacci series up to the 5th term. Input: n = 10 Output: 0 1 1 2 3 5 8 13 2...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1662909928, "func_sign": [ "int[] Series(int n)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass Main {\n // Driver code\n public static void main(String[] args) throws Exception {\n BufferedReader br =\n new BufferedRe...
{ "class_name": "Solution", "created_at_timestamp": 1663405036, "func_sign": [ "series(self, n)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n\n for _ in range(t):\n N = int(input())\n ob = Solution()\n result = ob.series(...
eJzs3T2uLcGyHGYZGsjCtWTQ6K7+qWqNRIAIyBCfIeeJxiMggCChgXISnIHiizo0ZDwaMoVzL/F47jl7r9U/VVmZkRGR//f/+L/8l//pv/4P/+t//Mf/8c///j/8yz/+598/zn/7z8e//ed//JvfP/7p//r3//S//8s//bv/7f/8D//y5x/zL/85//if/s3v//0b57/+G7/zX/ud/87X/M78d/yu3/Nbv/P6jfN33b/n+Vc/6vj/8GG/9f3O+/6N6/pdc/7e8/h9a/7O55u/8az7d5/r/L3zfX7n8d3v75zzzEet95m/+73e9ZvPMfKv...
706,070
Ruling Pair
Geek Land has a population of N people and each person's ability to rule the town is measured by a numeric value arr[i]. The two people that can together rule Geek Land must be compatible with each other i.e.,the sum of digits of their ability arr[i]must be equal. Their combined ability should be maximum amongst all th...
geeksforgeeks
Medium
{ "class_name": "Solution", "created_at_timestamp": 1619437068, "func_sign": [ "static int RulingPair(int arr[], int n)" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*; \nclass GFG{\n public static void main(String args[]) throws IOException { \n Scanner...
{ "class_name": "Solution", "created_at_timestamp": 1619437068, "func_sign": [ "RulingPair(self, arr, 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 arr = list(map(int, input().strip().s...
eJytVMtOw0AM5AD/MdpzQbvrfSR8CRJBHCAHLqGHVKqEWvER8K/cwBvh0KK6JaWjrGRFa3viGef1/P3z4mzAzQcHty/mqZsvenMN45quPFZgZjDtct4+9O3j/fOi/752yZfWTWdWM2wn+81k1IKpZZxtujEZTgDnKcSUqxp1lVMM5B2iAEGAJAAJ4AXIAoWWK4Vt6aDQi8xwBxN5ZSGBgwRe6yWwSi/iXpgw0/GqNttCXnruLIxKcHBSqoAVWwGEiIwiG8FxoFKmPd/uCcNsHSnZkYKSHgYzwvMhPmG6ndkAzJ1YRtY5ICck1TRZU/Bn...
700,428
Pots of Gold Game
Two players X and Y are playing a game in which there are pots of gold arranged in a line, each containing some gold coins. They get alternating turns in which the player can pick a pot from one of the ends of the line. The winner is the player who has a higher number of coins at the end. The objective is to maximize t...
geeksforgeeks
Medium
{ "class_name": "GfG", "created_at_timestamp": 1618331128, "func_sign": [ "public static int maxCoins(int A[],int n)" ], "initial_code": "import java.util.*;\nimport java.lang.Math;\nclass Pots{\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint t = sc.nextInt()...
{ "class_name": "Solution", "created_at_timestamp": 1618331128, "func_sign": [ "maxCoins(self,arr, n)" ], "initial_code": "# Driver Program\nif __name__ == '__main__':\n t = int(input())\n\n for i in range(t):\n n = int(input())\n arr = list(map(int, input().strip().split()))\n ...
eJyllEFOwzAURFnAPUZeV2hs12nCSZAwYgFZdGO6SKVKVRF3ADacFttJRRD6Ttomiuwonmd7/Cfv11/fN1f5uv+InYe9WofNtlN3UNoH54MmCY1RoxZQ7W7TPnfty9PrtjsOJ40Pbz6owwJ/MZUPBk2U1xEAIwEaQb6Kq4DuZ+9bgbAUAJrpgSEssSQcUREroiYaJqwAtKSEjHt1zNpITODE79/10LfDt/TuZN8qeZLeftlwSWiO53aW2ma/s14QSwc9qpeziyUfFv7dAsgVrJMKuLAsPb0xukui8AuaAZmxmhSoIqS4JcOZmDhQBI2s...
703,470
Chocolate Station
Geek has an array arr, where arr[i] (1-based indexing) denotes the number of chocolates corresponding to each station. When he moves from station i to station i+1 he gets arr[i] - arr[i+1] chocolates for free, if this number is negative, he loses that many chocolates also.He can only move from station i to station i+1 ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "public long getChocolateCost(int[] arr, int price)" ], "initial_code": "import java.io.*;\nimport java.util.*;\n\nclass Main {\n public static void main(String args[]) throws IOException {\n BufferedReader read = new...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "getChocolateCost(self, arr, price)" ], "initial_code": "if __name__ == '__main__':\n tc = int(input().strip())\n while tc > 0:\n arr = list(map(int, input().strip().split()))\n price = int(input().strip())\...
eJztVj1PwzAQZWDjTzx5rpCd9EjNL0GqKwaagcXtkEqVEBIbGxP8X84pH6X4XAelCkU4iX125Mu78/OLH05fns5O2nL1yMb0Tt365apRl1DGeaO1BvHTt9G6ViOoer2sb5p6fr1YNe/f1aE4r+5H2IGDg1/Ok4SL4pg0LCaocAHCGCUKdsOBcltyn3i84veWQ3e+EFwXUdchYWPaJO6IW+crEuIuKxJWOvDEWou/ZYTAUqyPpoJvaY6UusSUIbdW5zhw2OpnKtTqGAatEzyioRa46/Jmed3uZOLIASQQzqR3jhH4gB71Uv8LdTD0L1bq...
703,846
Sum of Digits Prime/Non-Prime
Given a number N, you need to write a program thatfinds the sum ofdigits of the number till the number becomes a single digit and then check whether the number is Prime/Non-Prime. Examples: Input: N=5602 Output: 0 Explanation: 1st step=5+6+0+2=13 2nd step=1+3=4 Since 4 is not prime, so answer is 0. Input: N=12 Outp...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "int digitPrime(int N)" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader read =\n ...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "digitsPrime(self,N)" ], "initial_code": "# Initial template for Python\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n ob = Solution()\n print(ob.digitsPrim...
eJxrYJm6k5UBDCI2ARnR1UqZeQWlJUpWCkqGMXmWMBCTp6SjoJRaUZCaXJKaEp9fWgJVZBCTVweUrNVRQNVpaAADJGu1tDA3MzUxNjIk3VIjYxNTM3MLMpwL1InPRkNc+mCAZBstoIAcp5ITpCTrgYUl6REI0oliQIxRHnkmGRqZg2OTmPDCFUVI/sDmMHIchZrUyIgOIEB1GSSTxVBiDnIqppKZqJkRagNa5qaGhWYkhQbOvEhMXEMyawxZWRYeNChhQ5UwIzs0Y6foAQAHkLY2
705,082
Sums of i-th row and i-th column
Given a matrix A of dimensions NxM. Check whether the sum of thei**throw is equal to the sum of thei**thcolumn.Note: Check only up to validrow and column numbers i.e if the dimensions are 3x5, check only for the first 3 rows and columns, i.e. min(N, M). Examples: Input: N=2,M=2 A=[[1,2],[2,1]] Output: 1 Explanation: ...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "int sumOfRowCol(int N, int M, int A[][])" ], "initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n Buff...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "sumOfRowCol(self,N,M,A)" ], "initial_code": "# Initial Template for Python 3\n\nimport math\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N, M = map(int, input().strip().split(\" \"))\n ...
eJy9VEFugzAQzKHKO0Y+R5EBm5S8pFKpekg59EJzAClS1SqPaF/RW1/Y2XVVyAGKUQQWYe2sxzPDLuebz+/1Sq+7Lwb3r+a5PraN2cMkZZ1Afqy1ZW02MNXpWB2a6unxpW26pHf++bbB5c4MWdgJjrK2CLFEIZ6H+AfXf0QCpUoNqi0FxyCCHaNSFAUxmOIpzAdxTtf8iLohSAenfiHlnfF2AtKbiGk8uZtIJvd1E8mMNsPD/5oRDIkJI4/KkYtEUiVTqqBPyMk418jpaipqrpsVyXKHW33B/bHUwpwyTKD17ODFXrJHEQckfTSQf81y...
703,981
Angle between hour and minute hand
Calculate the angle between the hour hand and minute hand. Examples: Input: H = 9 , M = 0 Output: 90 Explanation: The minimum angle between hour and minute hand when the time is 9 is 90 degress. Input: H = 3 , M = 30 Output: 75 Explanation: The minimum angle between hour and minute hand when the time is 3:30...
geeksforgeeks
Easy
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "static int getAngle(int H , int M)" ], "initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedRea...
{ "class_name": "Solution", "created_at_timestamp": 1615292571, "func_sign": [ "getAngle(self, H , M)" ], "initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n H, M = map(int, input().split())\n\n ob = Solution()\n ...
eJydkj0OgkAQhS04yGRrMDvjLgvWdl7ARIyFUtggBSQmRuMh9L4uiIWGhxEqEvgy7+8WPJbBpH1WC/+yPqtDUdaVmpPirIjJWBWSyk9lvqvy/fZYV93X2GXFNSvUJaRPhoU0YDRCiNEZK4hhsimCAGPJojsMDzkS5Ic1dKSJIcVIX0IWQTPEGDL/yxMSFIRDvXpGmjgQGLm0VyNS9/UbjZ2b304bOJJlTG8KenRLQjQYhIVgRyKlnBg89tal9m3DuiPud/oOaTAll8rAWF5+m4X+Ln9znz4BMxhQWA==