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 |
|---|---|---|---|---|---|---|---|
703,988 | Sum of elements in a matrix | Given a non null integer matrix Grid of dimensions NxM.Calculate the sum of its elements.
Examples:
Input:
N=2,M=3
Grid=
[[1,0,1],
[-8,9,-2]]
Output:
1
Explanation:
The sum of all elements of the matrix is
(1+0+1-8+9-2)=1.
Input:
N=3,M=5
Grid=
[[1,0,1,0,1],
[0,1,0,1,0],
[-1,-1,-1,-1,-1]]
Output:
0
Explanation:
T... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1619347516,
"func_sign": [
"int sumOfMatrix(int N, int M, int[][] Grid)"
],
"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": 1619347516,
"func_sign": [
"sumOfMatrix(self,N,M,Grid)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N, M = map(int, input().strip().split(' '))\n Grid = [... | eJxrYJm6h4UBDCK2AhnR1UqZeQWlJUpWCkqGMXmGCiDCwMBASUdBKbWiIDW5JDUlPr+0BKYEKBWTVxeTp1Sro4BFqy4evbp4NBspGEHsVYAogjNxmGVCwCiwXQpQG5E4uJyGyzx8mjCUEqcO6ERjBeOYPAMFIESlcBiAy6dgYxB+U0D2LbL/0ZSQGLVEeh8lEnXRnUKiz7AlB/yONyaUMElygi4JsW4AdyHRAWWoYEBeNtM1RAoPYh0ITSRk6ATpIi9DYTMKf+mAGQM4FcZO0QMArx1d3A== |
701,873 | Count subsequences of type a^i, b^j, c^k | Given a string S, the task is to count number of subsequences of the form a**ib**jc**k, where i >= 1, j >=1 and k >= 1.
Examples:
Input:
S = "abbc"
Output:
3
Explanation:
Subsequences are abc, abc and abbc.
Input:
S = "abcabc"
Output:
7
Explanation:
Subsequences are abc, abc,
abbc, aabc abcc, abc and abc.
Constrai... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1618167386,
"func_sign": [
"public int fun(String s)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n\tpublic static void main (String[] args) {\n\t\t\n\t\tScanner sc = new Scanner (System.in);\n... | {
"class_name": "Solution",
"created_at_timestamp": 1618167386,
"func_sign": [
"fun(self,s)"
],
"initial_code": "# Initial Template for Python 3\n\n# Position this line where user code will be pasted.\n\nt = int(input())\n\nfor _ in range(t):\n s = input()\n print(Solution().fun(s))\n print(\"~\"... | eJylVc1OhDAQ9mB8DtLzxtAfttQnMRFj6MjBC+6BTUyMxofQV/TmO9jC0izIV0CGScuBmX7zzTfl4/Lr5+qitdtv93L3yp7qw7FhNwnjRV06s87IGdslrHo5VNRUjw/Px+b0lZQ6K+r3omZvu2QYTdaWFLzbLLkVpOLacJTKmQfiAYHoFIT6Coj8wa2D6H2qUbz1sM8KsZEKpJIQRjAbjIKhhEoIpXJlIMVlR2mHknp88WK10CnEaWPPGu5Fy92k98D96tB67H5DcJXo0O4zJLVxf4aOyM0NbtefriMpYDUojdo2Gq1VkpjhmqbJXsZ0... |
703,537 | Even Decimal Binary String | Given a binary string of size N,you have to return the number ofsubstrings that haveeven value in its decimal form.Note: Most significant bit is on the right end side. For example - binary representation of 6 is 011.
Examples:
Input:
N = 3
S = "101"
Output:
2
Explanation:
Substrings in S:
1, 10, 101, 0, 01, 1
Corr... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static long evenDecimalSubStr(int N, String S)"
],
"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 voi... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"evenDecimalSubStr(self, N, S)"
],
"initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n S = input()\n ob = Solution... | eJxrYJn6goUBDCIeAhnR1UqZeQWlJUpWCkqGMXlAZKCko6CUWlGQmlySmhKfX1qCkK2LyVOq1VHA0GKIQ4sBDi1GQFtwWWOMW48hqfYYGoA0wQAZmg3gAIdmU1N8VhvAIA7dRvh0wzXjcrgxVpfjsgvTElNo4JASLgZ4kwi6YuLdguphhNtI9T0kocTEAHXidSlxmpHTADmpB6uHSPcRXncRldBwmQxyFdhcMnIwmntiMBI9FUMuJsYALT8Smzpip+gBAHpnfWs= |
701,265 | Transpose of Matrix | Write a program to find the transpose of a square matrixof size N*N. Transpose of a matrix is obtained by changing rows to columns and columns to rows.Example 1:
Examples:
Input:
N = 4
mat[][] = {{1, 1, 1, 1},
{2, 2, 2, 2}
{3, 3, 3, 3}
{4, 4, 4, 4}}
Output:
{{1, 2, 3, 4},
{1, 2, 3, 4}
{... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1687267797,
"func_sign": [
"public void transpose(int n,int a[][])"
],
"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 Bu... | {
"class_name": "Solution",
"created_at_timestamp": 1687503081,
"func_sign": [
"transpose(self, matrix, n)"
],
"initial_code": "# Initial Template for Python 3\n\nfor _ in range(int(input())):\n n = int(input())\n matrix = [\n list(map(int, input().split()))\n for _ in range(n)\n ]\... | eJzdV02O9FQMZMEBOII1669Qv/88ToJEIxYwCzbNt5hPQkIgDgGXY8dNqLK7J8n0ZJgVCxKN1PPi92yX7ark98///PuLz/z6+i/++OaXhx8vHz89PXxlD+l8aedLsmzFqvFnt2GLTUsnLidL2VKxVC3JrFsalhZL0zKfZ+7Llovlark9fLCHx58/Pn7/9PjDdz99erp5MO7iQd0ynWUerzMHd54vha50/MJDzpcqt9UPrwyLIdArHfHs8+W38+Xh1w+2D52bkE63y2j//A+fzNtlyZ5/b9bp9Xl9OYh+e/zmwPWM84VejblsDFe7jdmr... |
702,929 | Check if divisible by 4 | Given a number N. Check whether it is divisble by 4.
Examples:
Input:
N = 1124
Output:
1
Explanation:
The number is divisible by 4
as 1124 % 4 = 0.
Input:
N = 7
Output:
0
Explanation:
The number is not divisibly by
4 as 7 % 4 = 3.
| geeksforgeeks | Easy | {
"class_name": "Sol",
"created_at_timestamp": 1615292571,
"func_sign": [
"int divisibleBy4(String N)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nclass GfG\n{\n public static void main (String[] args)\n {\n \n Scanner sc = new Scanner(Sys... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"divisibleBy4(self, N)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input())\n for tc in range(t):\n s = input()\n ob = Solution()\n print(ob.divisibl... | eJy9VMtKxDAUdSH4FUIJLgfJ4yZN/RLBiAvtwk2cRQcGRJiPGP/Xm8dMW5smdSieW4Y2k5ycnJzkcP19d3Pl8XiLL0+f5N1udx15qIgwllEOxnJJjW10rSQITjYVaffb9rVr314+dl3szIzFTvhLvjbVgITjyAj8mwuQaoYhOVwaC9TDyVDGaoaMtURtCualhCfJCG5VWEhQ6wa7AMJYwYDJZl4aPTFO6XSEI/bg5zcnO/rGaMm5KbnobTdWRqARAUXCX2zYoqMqPT80sQEBo4XyUOgbhHJ2xrp4W3w6cFP6VbPz7KD7IGUSRE+TJJx0... |
705,582 | Replace O's with X's | Given a matrix mat of size N x M where every element is either 'O' or 'X'. Replace all 'O' or a group of 'O' with 'X' that are surrounded by 'X'.
Examples:
Input:
n = 5, m = 4
mat = {{'X', 'X', 'X', 'X'},
{'X', 'O', 'X', 'X'},
{'X', 'O', 'O', 'X'},
{'X', 'O', 'X', 'X'},
{'X', 'X', 'O', 'O'}... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1616153578,
"func_sign": [
"static char[][] fill(int n, int m, char 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 ... | {
"class_name": "Solution",
"created_at_timestamp": 1616153578,
"func_sign": [
"fill(self, n, m, mat)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n n, m = [int(x) for x in input().split()]\n mat = []\n ... | eJztWM1OwzAM5sBDcLR6nlBbaQLxErlGoogD7MCl7LBJSAjEQ8AzcuMZaJd2qRPbSbeWFalY7Mc/n+3ETrx+nH/9XJzt/vR39eH2NXkq19tNcgNJVpQZVC+qKJMFJKuX9ephs3q8f95uGg0FRfleSd8WQNhp1k6zdilkaeURFGhMhmmoZuzeKx+NPMwkzT03VlND5z3AZOLck7CAfgRuqC0XZyVzaQQiW/CTqL/Fcl1vlrgNXkK2tFGTVIspSGX3l8qkWYVWTFhisWfpih1LX4wsKbGSxaK16FuMXMxbXDVxzcUdYxtdogDqLJ+8nOzx... |
705,223 | Swapping Triangles | Given an integer N and a matrix A of dimensions NxN.Swap the values of the triangle above the primarydiagonal with the values of the triangle below the primary diagonal.
Examples:
Input:
N=3
A=[[1,2,3],[4,5,6],[7,8,9]]
Output:
1 4 7
2 5 8
3 6 9
Explanation:
Swapping the upper triangle with the
lower triangle gives ... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int[][] swapTriangle(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 Buffer... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"swapTriangle(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 = [[0]*N for _ in rang... | eJztWMuOHEUQ5MBHcAzN2UL1fvhLkLyIA+yBy+DDWkJCIH+CD0b+XSKzenamp6t6awYOyNrN0mi7K+uREdlVmfnx27+/fPeN/v3wif+8++Pw6/H9h6fDWxzsw1GaMebheHiDw+Pv7x9/fnr85affPjydVNiJh+NfVPjzDdZjHceCPx5hPB6ewx3CaJKok1ArgP8mZBRUWO7IWlgH62EDrKgl2AxbYCsc+x3HOTgPF+Dizg44jlMlcIBsJeu0WQbL3osuUWSih2OQtYOuIDuO3AjX5nJcYWSBXyxoSOL5Z/s83OFZUTZ4+eRXT9310wWC... |
701,271 | Boundary traversal of matrix | You are given a matrixof dimensions nx m. The task is to perform boundary traversal on the matrix in a clockwise manner starting from the first row of the matrix. Example 1:
Examples:
Input:
n = 4, m = 4
matrix[][] = {{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12},
{13, 14, 15,16}}
Output:
1 2 3 4... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1618656612,
"func_sign": [
"static ArrayList<Integer> boundaryTraversal(int matrix[][], int n, int m)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])th... | {
"class_name": "Solution",
"created_at_timestamp": 1618656612,
"func_sign": [
"BoundaryTraversal(self,matrix, n, m)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n n, m = map(int, input().strip().split())\n v... | eJztWstuG0cQzMGn3PwHDV5yEYx5P/wlAcwgh0SHXDY6SECAwIY/wv7fVPXsio/dJamANClhDR4ocrYf1dU1PUN/fff9/S8/6b9ff8abT/+u/uoenh5XH2Xl112QsO6sOPESJEqSLEWqWCPWinVivdggNopN6y5KXHcOq504Ly6Ii+JM/4hLYisMWD7sstgCewF2XRGLP5NagS14hbt1V6tUPJilJqlRaljdyer+n4f7Px7v//z976fHPsohuqLxbMzAZ5R192UcUqJ/ut0EryEURoiA9aGN+6DuU/t49flOtiByDDZOQ7TuPPMYfXUk... |
703,249 | Front-Back Transformation - copy | Given a string S, consisting only of english alphabets, replace all the alphabets with the alphabets occuring at the same position when counted in reverse order of alphabets. For example, 'a' would be replaced by 'z', 'b' by 'y', 'c' by 'x' and so on. Any capital letters would be replaced by capital letters only.
Examp... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"String convert(String s)"
],
"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 read = ne... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"convert(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 ans = solObj.conv... | eJytVEmO01AUZIHENSKvW0i9Zed5TOJ5Igh5jIfE8Ty1QBwC7sCOKxIQrbbVPHeM8OovrKp6r+rVl9fffrx59fszv18f7x+QOMubGnm3Qe4PGeriPhnSEZvwyN0GCfo88OrA/3hp6j8/2YPZ6Y1ayYV4yD4fMuTT3WaOMdqD1Zud0eqNBoA4qIt5uE8EZEgBKNtsn0ulUmut0VsjgLM7CykXM0cqIDzMAZDEXCrkUqnUWmv01ujM3hrsEXUwF/cInwyokD4yERtzCZ8CPHzKJWzMRPSRCsmA8HEPc1HHHq3B7I1Ob7VGrZVKLqVCzAEV... |
700,356 | Equal Sum and XOR | Given a positive integer N, Your task is to complete the function countValues which returns an integer denoting the count of all integers i such that0 <= i <= n and n+i = n^i where ^ denotes a XOR operation.Input:The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each... | geeksforgeeks | Easy | {
"class_name": "GfG",
"created_at_timestamp": 1619348482,
"func_sign": [
"public int countValues(int n)"
],
"initial_code": "//initial code\nimport java.util.*;\n\nclass EqualSumAndXor\n{\n public static void main(String[] args)\n {\n Scanner sc=new Scanner(System.in);\n int t=sc.next... | {
"class_name": null,
"created_at_timestamp": 1619348482,
"func_sign": [
"countValues(n)"
],
"initial_code": "# Your code goes here\nif __name__ == '__main__':\n t = int(input())\n for i in range(t):\n n = int(input().strip())\n print(countValues(n))\n print(\"~\")\n\n# Contribu... | eJydVMtugzAQ7KHqdyCfUWUbTCE/kFvOkeqqh4RDLy4HkCJFqfoRyf/GXkTrlt3lgZB52LOzO7P29+Nt9/QA137rX17P4sM1XSs2iVDWKZEmoj419aGtj++fXfs79WWduKTJv/VSSgpSYBhtnb+rqiJQGkA5Bs2sk9YZKXlagJYw4in0aS/K2kN4vvF6ukS0OAPFqUGdGSX2Y6wXkftP3AwWeia/7gU0Ah6WRUdcefQn/l9Gs1RxSgd2E5hLz5ppDy1MznZB9udR5PEX5imqIVVeOZEoJ5sLk/PrMEqPHGPahms2jaYdEB43ZTQXueC3... |
701,283 | Binary String | Given a binary stringS. The task is to count the number of substrings that start and end with 1. For example, if the input string is “00100101”, then there are three substrings “1001”, “100101” and “101”.
Examples:
Input:
N = 4
S = 1111
Output:
6
Explanation:
There are 6 substrings from
the given string. They are 11... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1619084131,
"func_sign": [
"public static int binarySubstring(int a, String str)"
],
"initial_code": "import java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\nclass GFG{\n public static Scanner sc = new Scanner(System.in);\n\tpublic static void ... | {
"class_name": "Solution",
"created_at_timestamp": 1619084131,
"func_sign": [
"binarySubstring(self,n,s)"
],
"initial_code": "import atexit\nimport io\nimport sys\n\n_INPUT_LINES = sys.stdin.read().splitlines()\ninput = iter(_INPUT_LINES).__next__\n_OUTPUT_BUFFER = io.StringIO()\nsys.stdout = _OUTPUT_BUF... | eJxrYJnqyMIABhFWQEZ0tVJmXkFpiZKVgpKBko6CUmpFQWpySWpKfH5pCVRcqVZHAUmZYUweEOFSbBCTVxeTh1WLIYlajIC2kGoNUI8hLnsM8eghwx4DUv1jCnKbIW7n4dJnBnIfCOLQaIxbH1gbLgux6sMZ4jj9Aw1AnP4yIxAchPTjDBewNpIizoC8tEsNl5KeXGCpmYycA9eKaowBiSYZ4EkMsVP0ABXjVX4= |
701,256 | Make Matrix Beautiful | A beautiful matrix is a matrix in which the sum of elements in each row and column is equal. Given a square matrixof size NxN. Find theminimum number of operation(s) that are required to make the matrix beautiful.In one operation you canincrement thevalue of any onecell by 1.Example 1:
Examples:
Input:
N = 2
matrix[][]... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1691817228,
"func_sign": [
"public static int findMinOperation(int N, int[][] matrix)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\nclass IntMatrix\n{\n public static int[][] input(BufferedReader br, int n, int m) throws IOException\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1692023092,
"func_sign": [
"findMinOpeartion(self, matrix, n)"
],
"initial_code": "# Initial Template for Python 3\n\nfor _ in range(int(input())):\n n = int(input())\n matrix = [list(map(int, input().split())) for _ in range(n)]\n ob = Solution... | eJxrYJlax8YABhHlQEZ0tVJmXkFpiZKVgpJhTB4IGYBBTJ6SjoJSakVBanJJakp8fmkJVBVQpg4oWaujgKmVZE1GQE0KcBuhDAWyzDFQMIASJOo1BmuD6kaiSDfGUMFIAUiZKJgqmMXkmStYKFjiNMbIHJ85hqAwQKVIdI4JVCPcBOwMEk01BUeSAhqmjSCp6c8A7i1kOMQFyclPSBkKysKbpwwNLC1hGihJSkbkZRgKc4wBDtXYCygDeMhQUsCADYshPmQg9sbEkGGzAs5wAjkGd5xaWGINLKAeksIL5HZEMiItORrgtip2ih4A2l7L... |
703,141 | A guy with a mental problem | A person needs to reach home by train but compulsively switches trains at every station. If they start with train arr1 at the first station, they will switch to train arr2 at the next station, and then switch back to train arr1 at the following station, and so on. Similarly, if they start with train arr2, they will swi... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1616524107,
"func_sign": [
"public int minTime(int[] arr1, int[] arr2)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\npublic class Main {\n public static void main(String[] args) ... | {
"class_name": "Solution",
"created_at_timestamp": 1616524107,
"func_sign": [
"min_time(self, arr1, arr2)"
],
"initial_code": "if __name__ == \"__main__\":\n import sys\n input = sys.stdin.read\n data = input().splitlines()\n\n t = int(data[0])\n index = 1\n for _ in range(t):\n ... | eJy1VUsOgjAQdWHiNSZdEwMtYHThOUzEuFAWbtAFJCZG4yH0vpapLb8WqGDbxUxhXh/TN8Nz+l7PJjg2C25sb+SUXLKUrIB4UZIvF0fVJg6Q+HqJD2l83J+ztIh48Id3B5owgwCoCoUlDrEF1IhEDUgsD5NYwqfKN8OZiPFwQQg8xQyPkLtGRGZA9JEgKJJiRxIuU7ekGmDCgIEPAXoBtxjfsYcK69cBrS4G9HkRuvQRmgTmqqyVp5Kuq01hu2UvUj0J3ZTE6C/E/vcB2iqzLDCp3w7FJaPrG3NpGePbh+SrKIEe2jfVi1evCZ4UlPLX... |
704,459 | Number Of Open Doors | Consider a long alley with a N number of doors on one side. All the doors are closed initially. You move to and fro in the alley changing the states of the doors as follows: you open a door that is already closed and you close a door that is already opened. You start at one end go on altering the state of the doors til... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1619174244,
"func_sign": [
"static int noOfOpenDoors(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 BufferedReade... | {
"class_name": "Solution",
"created_at_timestamp": 1619174244,
"func_sign": [
"noOfOpenDoors(self, N)"
],
"initial_code": "# Initial Template for Python 3\n\nimport math\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n\n ob = Solution()\n ... | eJydU0sOgjAQdcFBSNfEOJ2hUE9iIsaFsnCDLCAxMRoPoTdx5+Xk6y++JjAppGT6eNM3by7e7eFNmljcq83yqHZZXhZq7itKMlKBr9JDnm6KdLvel8U7dU4ydQr8n/MGAAQAYsRgAcC2wVGV/I9kMlojdKwlJBOyA82CitUkkcRsBJOLYZkhcTRLaKLYQjTVAUuPTCisyVG6aIO4MSe67GAEtShkAUZEmAk1ojcBBNZZrMRwMWzbvo9L9p20lux4C1dfSQKHxuXk3osOHzrpm9lzjdAYJQYKQd3zLchr1cpUb1hk99fVdfoEN353rg== |
704,433 | Reach the Nth point | There are N points on the road, you can step ahead by 1 or 2 . If you start from a point 0, and can only move from point i to point i+1 after taking a step of length one, find the number of ways you can reach at point N.
Examples:
Input:
N =
4
Output:
5
Explanation:
Number of ways to reach at 4th
point are {1, 1, 1, ... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int nthPoint(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 {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"nthPoint(self,n)"
],
"initial_code": "# Initial Template for Python 3\n\nimport sys\nsys.setrecursionlimit(10**6)\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n = int(input())\n o... | eJylk89Kw0AQhz30QcKei8z/nfVJBCMeNAcvsYcUCiL4EO1jePMBTYONCjupaE6B7Dffzswvr6vD++pieq7fxpeb5/TYb7ZDumoStj1CWjep2226+6F7uHvaDp/fvLR9elk3P49TdByhiNUIjQg2hZFiqVEIEZadCGS01WURpsRgjpQDW9xX1lwKV6ehMSdYDAo5Rr4IJCFiIY98oVBQiLNWwUkYkcWyoRNTVXnShrSOQy2etU7D0f69zEIiiNmzCEQtzDWiAkZKGTUI4tdd/naDxTGwOqOB1/MVxxn5OH2LYnLSnln+YuN4LgAo0T84... |
705,705 | Help a Thief!!! | You have to help a thief to steal as many as GoldCoins as possible from a GoldMine. There he saw N Gold Boxes an each Gold Boxes consists of Ai Plates each plates consists of Bi Gold Coins. Your task is to print the maximum gold coins theif can steal if he can take a maximum of T plates.
Examples:
Input:
T =
3,
N =
... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int maxCoins(int[] A, int[] B, int T, int N)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader read =\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"maxCoins(self, A, B, T, N)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n T, N = map(int, input().split())\n A = list(map(int, i... | eJy9VcFOwzAM5cCBz7ByRBNq0jotfAkSRRxgBy5lh05CQiA+Av4Xv7TpNLVO6Sro1Jc08vxs5zn5PP+2F2fhub2Uyd2beW52+9bckLF1YzN5qOgm5AB5WBGoG8a0M7EcDTKzIbN93W0f2+3Tw8u+jd5gkYX/fdSNed/QMVVwwHEcQwzmWh5ABSgBXmGcIbRd9IfckBoyAx15eUt5K1D2aYopjX5aujqxOIcnRzkVxPjwMhTy6VR3mi+HWMs+B8RqXb8bZKu4ZTAKJlqWWg4lz9Qv7Ji6L3UzsQhghRDmCcbgzU5vQyKMwAgoADnAAbRa... |
702,894 | Smallest subarray with sum greater than x | Givena numberx andan array of integers arr, find the smallest subarray with sum greater than the given value. If such a subarray do not exist return 0 in that case.
Examples:
Input:
x = 51, arr[] = [1, 4, 45, 6, 0, 19]
Output:
3
Explanation:
Minimum length subarray is [4, 45, 6]
Input:
x = 100, arr[] = [1, 10, 5, 2,... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1618657724,
"func_sign": [
"public static int smallestSubWithSum(int x, int[] arr)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\npublic class Main {\n public static void main(String... | {
"class_name": "Solution",
"created_at_timestamp": 1618657724,
"func_sign": [
"smallestSubWithSum(self, x, arr)"
],
"initial_code": "def main():\n T = int(input())\n\n while T > 0:\n x = int(input())\n a = [int(x) for x in input().strip().split()]\n print(Solution().smallestSub... | eJytk8FKxEAMhj3oe4Q5L5JkJq27TyJY2YNW8FL30AVBXHwIfV+TmbKwSNZOtafSId/8/5+/H5dfT1cX+bnd6svdW3gedvsxbCBQNwh2AwEhCDC0cAPEwPotrCD0r7v+Yewfty/7cZpouuGgh+8rOMW0ohhFMMTCSEZsXI44HEK9mwWUFRGiZGUuJTkUzq5QRxFaVWWwainRpChA1IdiEBpfCDqMtblBM6FuLBJfRvQSsZkkk4xkoVQz1jpSYhAjpHoCUXGSozQ/uiA5sxkvEMa8Ga3YMZGSbvWOS+NEzveMPB3zI5mx2yi/bdfTcVoQ... |
712,306 | Postfix to Infix Conversion | You are given a string that represents the postfix form of a valid mathematical expression. Convert it to its infix form.
Examples:
Input:
ab*c+
Output:
((a*b)+c)
Explanation:
The above output is its valid infix form.
3<=post_exp.length()<=10**4 | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1666247053,
"func_sign": [
"static String postToInfix(String 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[] a... | {
"class_name": "Solution",
"created_at_timestamp": 1666332578,
"func_sign": [
"postToInfix(self, postfix)"
],
"initial_code": "# Initial Template for Python 3\n\n# Position this line where user code will be pasted.\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n postfix... | eJy9lM9u1EAMxjkgnmOVk8fuYOXKkyCRGiUzk39t022bbLJBIB4CXpUbEhPUqN12Z3YvMNrDHqLP/n7+7O9vf/5+9+bv+/jL//n0JWm67dAnHzZJmnV5YZCsY51cbBI3bZ3pnf18O/SPnwDkBAUapTRYdkpl3besS75ebF7qkLFOkCI6hSIwCFa8TEhn2tOMowy8C3fk30R7hbOSUfGg9C6sNosMuxEj/iaBvcyLv4Fhh2O4N8/KutJ71FzVGCHGUGgwBBbBSamWp6HCOqycF4UxiMzWEjmnI+YXdf9Dj9Isyr4M2aWA0+Hx3G7v7h96... |
701,448 | Strongly connected component (Tarjans's Algo) | Given a Directed Graph with V vertices and E edges, Find the members of strongly connected components in the graph.
Examples:
Input:
Output:
0 1 2,3,4,
Explanation:
We can clearly see that there are 3 Strongly
Connected Components in the Graph
as mentioned
in the Output.
Input:
Output:
0 1 2,
Explanation:
All of ... | geeksforgeeks | Hard | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public ArrayList<ArrayList<Integer>> tarjans(int V, ArrayList<ArrayList<Integer>> adj)"
],
"initial_code": "// Initial Template for Java\nimport java.util.*;\nimport java.io.*;\nimport java.lang.*;\n\nclass Gfg\n{\n public ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"tarjans(self, V, adj)"
],
"initial_code": "# Initial Template for Python 3\nfrom collections import OrderedDict\nimport sys\n\nsys.setrecursionlimit(10**6)\n\nif __name__ == '__main__':\n t = int(input())\n for i in rang... | eJydVMtOwzAQ5ID4jpHPFrIdJ3H4EiSMOEAkuLg9pBISKuIj4H/xOk1bSNZJk8PKj3hmd2btr+ufzc1V+u5f4+DhQ7yF7a4TdxDaB62gSx9ijGMYHwwUhcKHAtYHi7hb0rRC7UMN54NDRdPGh4ZGup8qQolrQkK079v2uWtfnja7buBCBEUEgUMjI6z04TP+vZf4m5GD1qOERrmUx4QqCpY26hw5URI9R5vQzln/KaBoo5gpL1OWNtB2vq6hJNfL6yho1ftEJzWtqz65JHvyQ+XzSnLXkpAiCpthBoY7YzB4xR1k6QxWclrYCafmJGBt... |
703,869 | Shortest un-ordered subarray | Given an array arr of distinct numbers. Find the length of the shortest unordered (neither increasing nor decreasing) subarray in the given array. If there is no subarray then return 0.
Examples:
Input:
arr[] = [7, 9, 10, 8, 11]
Output:
3
Explanation:
Shortest unsorted subarray is 9, 10, 8 which is of 3 elements.
In... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1617815784,
"func_sign": [
"public int shortestUnorderedSubarray(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... | {
"class_name": "Solution",
"created_at_timestamp": 1617815784,
"func_sign": [
"shortestUnorderedSubarray(self, arr)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n # n = int(input())\n arr = list(map(int, input()... | eJztVsuOHEUQ5OAjEgf/QGjObquy3uUvQWIQB9gDl8GHtYSEQHwE/C8RWdWeMd6ZZbGNhOQd7Wi6OisfkRFZ9fuzP59/9YX/ff0lf3zzy+HH0+s394dXOKTjqR5PBR0DCRWZD8eTBcSAFJADStAz//k+oiCj0W5wh4XDCxzufn599/393Q/f/fTmfjmlNf3y+7fj6fDrC1zEi8dTo6/CzfRVYQZLMC53hYgMIvdFAW56f9/1TH3AmGJF9MLkLXqq4DtaKF7Uo2V3oxzyY2U8GM4Y63giTLMYeWWcBmNRmUVdd/q+L4d8YVwcgL77NPdW... |
702,903 | Partition Point in the Array | Given an array arr[] of integers. Find an element such that all the elements to its left are smaller and to its right are greater. Print -1 if no such element exists.
Examples:
Input:
arr[] = [4, 3, 2, 5, 8, 6, 7]
Output:
5
Explanation:
To the left of element 5 every element is smaller to it and to the right of eleme... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int FindElement(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 stati... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"FindElement(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 ... | eJytlM1qwkAUhbsofY7DrKXMTyY/Pkmhli5qFqWQuogglEofon3fnhmNmpobHFPDYUaZHO755l6/bn/e7m7i52HJzeOHem1W61bNocyiMZqChUMGTznuDbSaQdWbVf3S1svn93XbvcDT20WjPmf4Y+ODFSqUKJCfOHXOueToBUcbCtMaljKeKqmKKoI8TH78LZxxVEb5sPK8p3Luc64F18JLoexoKPQfe/otNVOEPUApmbbdFWYj3h1gIuZTSFZ2BLOD29tkeyt/MIymrLeCSeZXBmtDS0OzirVKTVCO8DoW05UBkw6MN6Kh0Yd2ATbp... |
700,276 | Max sum in the configuration | Given an integer array(0-based indexing) a of size n. Your task is to return the maximum value of the sum of i*a[i] for all 0<= i <=n-1,where a[i] is the element at index i in the array. The only operation allowed is to rotate(clockwise or counterclockwise) the array any number of times.
Examples:
Input:
n = 4, a[] = {... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1616777501,
"func_sign": [
"long max_sum(int a[], int n)"
],
"initial_code": "import java.util.*;\n\nclass Maxsum_Among_All_Rotations_Array {\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n int t = sc.... | {
"class_name": null,
"created_at_timestamp": 1616777501,
"func_sign": [
"max_sum(a,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 = list(map(int, input().strip().split()))\n ... | eJydVEFOwzAQ7IH+Y+VzVXnXjp3wEiSCOJQcuLg9pFKlCsQj4Bfc+CB2iFBLNI7D2lEiOTPanfHu283H13o1xN1n/Lg/q+dwOPbqlhS3IW09hNqQ6k6Hbtd3T4/7Yz/+o9vw2gb1sqE/QJ0eaqgmT44qsmRIiAGNNIio+s2AZt6AejzN8dO4IAPAuoSVWJiNBTqA9jmJLpSJOtVRL0Z1GFiCjTurLtcAaS7EnZHRZFWMKWga1sJ7Im1ohihzcd6IfzvBCVnoBYuuilJhlEtkmCHgkeHHX0zkzaIW9PCWWINqmjJVeSovUiYP9MrCXCZu... |
703,818 | Find the fine | Given an array of car numbers car[],an array of penalties fine[], and an integer value date. The task is to find the total fine which will be collected on the given date. The fine is collected from odd-numbered cars on even dates and vice versa.
Examples:
Input:
date = 12, car[] = [2375, 7682, 2325, 2352], fine[] = [25... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1617813715,
"func_sign": [
"public long totalFine(int date, int car[], int fine[])"
],
"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)... | {
"class_name": "Solution",
"created_at_timestamp": 1617813715,
"func_sign": [
"totalFine(self, date, car, fine)"
],
"initial_code": "# Initial Template for Python 3\ndef main():\n T = int(input())\n\n while T > 0:\n date = int(input())\n car = [int(x) for x in input().strip().split()]... | eJzNVstuE0EQ5MCJryjtOULzfvAlSBhxAB+4LDk4EhIC8RHwcdz4FLprJoRA2lbsWKQPtevdntma6uoZf336/eezJ4yXP+Tm1afl/Xp5tVteYPGbtWtsVq+BoIGogaSBrCGvnXMIClEhKWSB5QLL9uPl9u1u++7Nh6vdnLfIq836ZbMuny9w+3s6kxsXD8VAjMREzMRCrMRG7Iqeg4WLMBEewgLFoTo0h+40w+AUskUppxiuL1AMxEhMxEwsxEpsxK4YZeLeKkpO0CnkuT7m71oyWi3Q9/Lc4BZdapZeIaY8yoQmgSqBIsHasEysGIsH... |
703,338 | Jay's Apples | Given a queue of persons represented by an array of integers, where each person is identified by a specific integer, find the minimum kilograms of apples that need to be distributed, ensuring that each person receives 1 kilogram of apples only once.
Examples:
Input:
arr[] = [1, 1, 1, 1, 1]
Output:
1
Explanation:
The... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int minimumApple(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": [
"minimumApple(self, arr)"
],
"initial_code": "def main():\n T = int(input())\n\n while T > 0:\n # Convert input to list of integers\n a = list(map(int, input().strip().split()))\n print(Solution().min... | eJy1k8EKwjAQRD2Iv+GQgyeRbNO01S8RrHjQHryohwqCCH6E/q+boFU0ihuxEOihs/NmOzm2z71Oyz/jLr9M9mq52mxrNYKickWaDxIYpLDIkKPAEKRVH6rabap5XS1m6219V6hDH4EZmmUFyzMek/K4BCSaYR2HI3EsjsbxOKIrk2RY4kOZQCwQmzCaAaUgC8pAOagAyQyYton5ZBBYBLRPZiQWljPIfoIWKqxY4TxiJGJNuJNRKT0ApZryWIRbOx9QqGm9iOVDL3VTzLhG3oHfEcN/VMoxxCnd5ZAIzAtQEiS6oUesx+qY5gRWWpYf... |
701,365 | Fractional Knapsack | Given weights and values of n items, we need to put these items in a knapsack of capacity w to get the maximum total value in the knapsack. Return a double value representing the maximum value in knapsack.Note: Unlike 0/1 knapsack, you are allowed to break the item here.The details of structure/class is defined in the ... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1729142017,
"func_sign": [
"double fractionalKnapsack(List<Integer> val, List<Integer> wt, int capacity)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GfG {\n\n public static void main(String[] args) throws IOException {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1729142017,
"func_sign": [
"fractionalknapsack(self, val, wt, capacity)"
],
"initial_code": "# Position this line where user code will be pasted.\n\nif __name__ == '__main__':\n test_cases = int(input())\n for _ in range(test_cases):\n # Rea... | eJzNVUtOw0AMZcGOS1jZIVWRPf9wEiSKWEAXbEIXrYSEQBwC7ss4k04ErfOpStR0ZFlRx362n18+L7+vry6a57aIzt1b8Vyvt5viBgpa1oSIoNhoNoaNZePYeDaBTcWG/4zxDuz9lrUtFlCsXterx83q6eFlu2lzcEQsEdPVj2VdvC9gH0ObIeSsLiMxGZ3ageA7UEEADw4sGNCgGIRCAYUahYITcCZOybkZBKNhWIxvl5tAEWgCQ2AJHIEnCARVbARyJCvBIBNM6cjqYCUUsRAdC7KxMB8LrGJIqVqSez6i4Zi7nryQPZ89lz2bPZM9... |
703,202 | Smallest distinct window | Given a string s, your task is to find the smallest window length that contains all the characters of the given string at least one time. For eg. A = aabcbcdbca, then the result would be 4 as of the smallest window will be dbca.
Examples:
Input:
"AABBBCBBAC"
Output:
3
Explanation: Sub-string -> "BAC"
Input : "aaab"
Ou... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1616696799,
"func_sign": [
"public int findSubString( String str)"
],
"initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\nclass GFG {\n\tpublic static void main(String[] args) throws IOException\... | {
"class_name": "Solution",
"created_at_timestamp": 1616696799,
"func_sign": [
"findSubString(self, str)"
],
"initial_code": "# Initial Template for Python 3\ndef main():\n T = int(input())\n while T > 0:\n string = input()\n ob = Solution()\n print(ob.findSubString(string))\n ... | eJxrYJlazMoABhE5QEZ0tVJmXkFpiZKVgpJhTF6iko6CUmpFQWpySWpKfH5pCUJKqVZHAU0xaaqTknEoN8ZueFJSMi4dJjgsSMFtCU4tqWnpOLSYY9NSUVFZBUGk+KaqsgKOSNHn6OTs4urm7uHp5e3j6+cfEBgUHBIaFh6BwwwjrL50dHR0cnJ2dnFxdXVzc3f38PD09PLy9vbx8fX18/P3DwgIDAwKCg4OCQkNDQsLD4+IiIyMisJhg6kBIe8ZxsQYgoIWHLo4E5Qp9jgHaYZqxKUTe2rBdATIGcgOwWWeETbz0IwjLaUj6USkMWyG... |
702,809 | Happiest Triplet | You are given the three arrays arr1[], arr2[], arr3[] of the same size . Find a triplet such that (maximum-minimum) in that triplet is the minimum of all the triplets. A triplet should be selected so that it should have one number from each of the three given arrays. This triplet is the happiest among all the possible ... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1617121167,
"func_sign": [
"int[] smallestDifferenceTriplet(int arr1[], int arr2[], int arr3[])"
],
"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[] ar... | {
"class_name": "Solution",
"created_at_timestamp": 1617121167,
"func_sign": [
"smallestDifferenceTriplet(self,arr1,arr2,arr3)"
],
"initial_code": "# Initial Template for Python 3\n\nt = int(input())\n\nfor _ in range(0, t):\n arr1 = list(map(int, input().split()))\n arr2 = list(map(int, input().spl... | eJzFVUtOxDAMZcGGW1hZj1Cb1J2WkyARxAK6YBNm0ZGQEIhDwNHYcRgSu6Hp0LTTTCVSKR/HyXPsZ/f9/PP74oza9Zed3LyIR7Pbt+IKRK5NDvYbDmIDonneNfdt83D3tG+9Mqu8aSNeN3BwS+YaDIYl0hjk6AXjFljrpBskKG0UqMR3gMxAWRBFs9zOEHIEiVETrRJg3Cq2Hdl05Icc+qITJxhcu+ZB3Lxi2ZYWJfXIooIWinoZgaIb+BD1RQSWDS4I3M1z5zAncr2NgdvQZkuikrTcPPZA1uDbFN8WZ5kNiwfKPGqwoU2wzxtT5IKg... |
702,812 | Min sum formed by digits | Given an array of digits (values are from 0 to 9), find the minimum possible sum of two numbers formed from digits of the array. All digits of the given array must be used to form the two numbers.
Examples:
Input:
N = 6
arr[] = {6, 8, 4, 5, 2, 3}
Output:
604
Explanation:
The minimum sum is formed by numbers
358 and ... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1617816232,
"func_sign": [
"public static long minSum(int arr[], 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 IOExce... | {
"class_name": "Solution",
"created_at_timestamp": 1617816232,
"func_sign": [
"minSum(self, arr, n)"
],
"initial_code": "import heapq as hq\n\nif __name__ == '__main__':\n T = int(input())\n\n for tcs in range(T):\n n = int(input())\n arr = [int(x) for x in input().split()]\n o... | eJytlMFKxEAMhj2IzxF6XmQmmUxmfBLBigftwUvdwy4IovgQ+o7efAUzs9siQrrbuk0PpbTfn/xJ5v388/virF7XX/pw89I89uvtprmCxre9d22fwUMCBAGCCAEYXLOCpnted/eb7uHuabsZfoguSNu/tX3zuoI/JGx7B05ZXlmoLFJWobFBwxCzs2hc8sqaV9K8RPOKhVSJhYwWM2ZPLMnAoup5xaJiSbFhjy1ll/KLDcUOZ1pQkp5U4J0Nu/Bj4Bg0RhjC0kIKIUZJlhjV7qXqD1dnsCZ/5DuryxhYO+Mp8IQ0FyexVlH8E8VnQ3ry... |
705,356 | Villain Con | The minions are very elitist in nature. If minion x admires minion y, then y thinks too highly of himself and does not admire x back. Also, if x admires y, x also admires everyone that y admires.
All theminions are going to be present at the Villain Con. They wantto make sure that they do not dress in thesame color as ... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int minColour(int N, int M, int mat[][])"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG{\n public static void main(String args[])throws IOException\n {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"minColour(self, N, M, mat)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N, M = [int(x) for x in input().split()]\n mat = [[0]*... | eJztlkuOHEUURRmwAXZwVWMLZfwjWAkShRhAD5gUHtgSEgKxAGbAfjk3XtvChhR02wjZUIPu6q6KGy9PnPcyf/zw158/+mC/Pv2JN599d/n69vT5s8snuqTrLR1KjV/K11tWud6K6vVWxf+a+vXWNa63oXm9Ta3rbSkd/rZ/Zv+3+PPqbzZ/nvnk8kSXu2+f3n357O6rL755/uzFZiz54Xq7fP9Er5bQKOE4HlwDq1w/tbAssTELU1FiaapxUU2J5akrEZCGEhFpKhGSlrKv4VAmJbO3N8/KpOSiTEquyqTkpkxK7sqk5KFMSp7Kvtyl... |
703,309 | Why is Melody so chocolaty? | Chunky gets happy by eating Melody. Given an array arr[], each element represents the happiness Chunky gets by eating the melody.Chunky knows why Melody is so chocolaty but will only tell you once you tell him the maximum happiness he can get by eating two adjacent melodies.
Examples:
Input:
arr[] = [1, 2, 3, 4, 5]
Ou... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int maxHappiness(List<Integer> arr)"
],
"initial_code": "// Initial Template for Java\n\n/*package whatever //do not write package name here */\n\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n publi... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"max_happiness(self, arr)"
],
"initial_code": "def main():\n import sys\n input = sys.stdin.read\n data = input().strip().split('\\n')\n\n t = int(data[0])\n index = 1\n solution = Solution()\n\n results = ... | eJxrYJm6kI8BDCJmARnR1UqZeQWlJUpWCkrGMXmGBiCgAKGAXAVLEFCACcfkQflQESUdBaXUioLU5JLUlPj80hKoQUZQ7XVAE8AaIEyQoCGYqVSro4BksRHIpmEBY/JggadABANX8CGCywBbcMGjASVyiBLCYSNSLKHZZYKWJhTQUwjMRwghLP5FdrAFmDQHk2Zg0hRMmhCRmLAzwebhSldGxiamCmbmFpZA1yDYCF8hIL4AsjAwMjYlnIrBXoWEBhLEYSbE9bhiGE+oE0ERDktMGwnoxZseYRFNsl4jhL2kmILXQFLjnMhIx1124beP... |
703,804 | Count the subarrays having product less than k | Given an array of positive numbers, the task is to find the number of possible contiguous subarrays having product less than a given number k.
Examples:
Input:
n = 4, k = 10
a[] = {1, 2, 3, 4}
Output:
7
Explanation:
The contiguous subarrays are {1}, {2}, {3}, {4}
{1, 2}, {1, 2, 3} and {2, 3}, in all these subarray... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1617641104,
"func_sign": [
"public long countSubArrayProductLessThanK(long a[], int n, long k)"
],
"initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG {\n\tpublic static void main(String[... | {
"class_name": "Solution",
"created_at_timestamp": 1617641104,
"func_sign": [
"countSubArrayProductLessThanK(self, a, n, k)"
],
"initial_code": "# Initial Template for Python 3\n\ndef main():\n T = int(input())\n while T > 0:\n n, k = [int(x) for x in input().strip().split()]\n arr = ... | eJy9VEtOhEAQdWE8x0uvJ6ar+kd7EhMxLpSFG5wFk5gYjYfQE7rzFFYDJupMMcDCBhqS5r36varX0/fPs5N+XX7Ix9WTuW+3u85cwFDdkkWwdnwjgMEWHEByw8GbDUzzuG1uu+bu5mHXjUjmun2pW/O8wR8+wdlCyIKOqJBQqJFBDPIju7NwAd4q7C4o7AXdsxffQuEmkAPJRwY7cIaTowRP8OJ9QpD/MiIhJiRS7HmrRVO8lcM4+i/BVWACSyCpj8IplOQ0SkYsEYQhL4c3LS8qqWBk13zRUTpIS4lIpEcOl2ZRK+CIllSWRwtTr0bR... |
702,382 | Sort 0s, 1s and 2s | Given an array arr containing only 0s, 1s, and 2s. Sort the array in ascending order.
Examples:
Input:
arr[] = [0, 2, 1, 2, 0]
Output:
0 0 1 2 2
Explanation:
0s 1s and 2s are segregated into ascending order.
Input:
arr[] = [0, 1, 0]
Output:
0 0 1
Explanation:
0s 1s and 2s are segregated into ascending order.
Con... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1724754594,
"func_sign": [
"public void sort012(int[] arr)"
],
"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(new Inp... | {
"class_name": "Solution",
"created_at_timestamp": 1724745105,
"func_sign": [
"sort012(self, arr)"
],
"initial_code": "def main():\n t = int(input().strip()) # Read the number of test cases\n ob = Solution()\n while t > 0:\n t -= 1\n # Read the array as space-separated integers\n ... | eJzVVcFOwzAM5cBhn2HlPCHbUi98B4dJK9oBeuBSdugkJDS0j4D/JUuc1mtwq0YgjaZq0zZ+fn55SU+3X9vVTTg2D76zfXcv7f7QuXtwVLeEdcuAwED+SnJntwbXvO2bp6553r0euhTgR3/UrTuuIYchyFoJDELWSmAYsrYUhgMbCsEUmIxUGvoGNFvQlTCMcAmMVQ+ln1KnxNyP4F5nBE2Twnec0L+yhZMJSJoN6NS/QZUvZURhlmoZOGhzjUdqYVnekIpF9aS1IS39SKukkW0as3hfuhVkh5get0NMI05k8dwKklU4Xg1ys0mEkN82... |
701,714 | Number of Unique Paths | Given a AX B matrix with your initial position at the top-left cell, find the number of possible unique paths to reach the bottom-right cell of the matrix from the initial position.
Examples:
Input:
A = 2, B = 2
Output:
2
Explanation:
There are only two unique
paths to reach the end of the matrix of
size two from the... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1618303175,
"func_sign": [
"public static int NumberOfPath(int a, int b)"
],
"initial_code": "//Initial Template for Java\n\n/*package whatever //do not write package name here */\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n\tpublic static ... | {
"class_name": "Solution",
"created_at_timestamp": 1618303175,
"func_sign": [
"NumberOfPaths(self,a, b)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n\n for _ in range(t):\n a_b = [int(x) for x in input().strip().split()]\n a = ... | eJydVDuOU0EQJEDcgWz04hXq/4eTIGFEABuQmA28EhICcQi4L/UWOyBow64Da+R2VddUV8+P57/Wi2cPnzcvcXj7dft0vLs/ba/XxoejL99u1nb75e72w+n24/vP96dzMelw/H44bt9u1t8QpsU0gKxCRpwvnpoZMUfQCI3FA5InyOJ4JKQWywBRLrGpk6x6CiyuKHRnTh+tzMU2QCVZZWppK58Cg1Kb/JcUso5wswgl15wTANl75AamIqoBCDcQujF16k3EVB1dyFGyW3dlZzOJ0P7F3OpU1OZJ7WqlWVLcGZrAEIvG/nNUhDhrkzCF... |
705,826 | Modified Numbers and Queries | Find the sum of all the numbers between the range land r.Here each number is represented by the sum of its distinct prime factors.Note: For example, 6 is represented by 5 because 6 has two prime factors 2 and 3 and 2 + 3 = 5.Example 1:
Examples:
Input:
l = 1, r = 2
Output:
2
Explanation:
1->0, 2->2 and 0+2=2.
1 has n... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int sumOfAll(int l, int r)"
],
"initial_code": "//Initial Template for Java\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG\n{\n public static void main(String[] args) throws IOException\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"sumOfAll(self, l, r)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n l, r = input().split()\n l = int(l)\n r = int(r)\n ... | eJytVMsOgjAQ5IB+R9MzmN2WttQvMRHjQTl4qRwgMTEaP0K/V4H4islWBPfQS3dmZ6abnsLLeBS0NbuGQTDf840rqpJPGcfMIUMeMZ7vinxV5uvltirvl5C5Y+b4IWIfCKiLtSeBNATS1uUFohDUUD8OBKYgNQFWjWD1u96k0VvjqIS0NtRIwSQBUnSsTJASlRLoc6c94aCQNpHUm3x7TEw1gv66DC8HJFNcNxiT2LQb11/JGq53iY1zN4D+EToFF0YCWNtJnIahZls18OuGewb2y7Pt6W0Chq4i/ZXFz69hcZ7cAHFxdU8= |
701,172 | Swap all odd and even bits | Given an unsigned integer N. The task is to swap all odd bits with even bits. For example, if the given number is 23 (00010111), it should be converted to 43(00101011). Here, every even position bit is swapped with an adjacent bit on the right side(even position bits are highlighted in the binary representation of 23),... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1618484728,
"func_sign": [
"public static int swapBits(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 BitWise{\n\n\tpublic static void mai... | {
"class_name": "Solution",
"created_at_timestamp": 1618484728,
"func_sign": [
"swapBits(self,n)"
],
"initial_code": "# Initial Template for Python 3\n\nimport math\n\n\ndef main():\n T = int(input())\n\n while T > 0:\n n = int(input())\n ob = Solution()\n print(ob.swapBits(n))\... | eJyFkj1Ow0AQhSlykMh1hOZ/ZzkJEkYU4ILGpHCkSAjEIeAadNwP24lAFG/ZaqV9b3bezPe2+fjaXKzn+nO+3Dx3j+P+MHVX2477kbvdthuO++F+Gh7ung7T+Un68bUfu5fd9q+egJ6Ank053Es4+ihDldkVVRC2YqlhBVRQERZxKwwqKDICvQF9oowkyCJk2FW0GKeg9n4FoIJrZKHKgj6PNHXzAP7CnlIykV+9VNZqaK6yjryRnkNKw9twmlsGUYOJpasFDGuQYVwFgbyCibFkJ3dKNLq1/dbeZZ5dTTh6+gnR278xYIQTIAvhiiBy... |
705,890 | Find maximum volume of a cuboid | You are given a perimeter & the area. Your task is to return themaximum volume that can be made in the form of a cuboid from the given perimeter and surface area.Note: Round off to 2 decimal places and for the given parameters, it is guaranteed that an answer always exists.
Examples:
Input:
perimeter = 22, area = 15
O... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"double maxVolume(double perimeter, double area)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"maxVolume(self, perimeter, area)"
],
"initial_code": "# Initial Template for Python 3\nimport math\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n perimeter, area = [int(x) for x in input()... | eJylVMtOxDAM5ID4jqjnlWXn0cR8CRJBHKAHLmUPrYTEQ3wE/C9h28BuF6cR61MUJeOZ8eP9/PPl4mwXV2M6XD83D/12HJpL1VDsCXOo32Psm41quqdtdzd097eP4zB/0G56oIF97N/Su9eNOgTkHOrnVAHntQDnjumJcHZKByEIYBlCVTJjdoAkgWljXetDEhp866zRIhqxdwaDB+Sia4pECIRv4QVVypXNabUjneS0K97gv0koXUhPyMBmLXdWURYy1Rm8qzFkMne6nS2WkZNJjlFu7gOiNZnWxNSWdR87xtN10HIOcoq5EUul1Nob... |
702,882 | Minimum Difference among K | Given an array arr[] ofintegers and a positive numberk. We are allowed to take any k integers from the given array. The task is to find the minimum possible value of the difference between the maximum and minimum of k numbers.
Examples:
Input:
arr[] = [10, 100, 300, 200, 1000, 20, 30], k=3
Output:
20
Explanation:
20 ... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1730200213,
"func_sign": [
"int minDiff(int[] arr, int k, int m, int th)"
],
"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": 1730200213,
"func_sign": [
"minDiff(self,arr,k,m,t)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n arr = list(map(int, input().strip().split()))\n k = int(input... | eJzFVEtOwzAQZYHENUZeF9TxJ7E5CRJGLCALNqaLVKqEQBwC7saOq+AZtwmqOiGJIuFaL5HqzJv3Zjzv55/fF2e8br7yy+2LekqbbauuQWFMCLimBYEWOH4nREYN+YyLSeeT9JdagWp2m+ahbR7vn7ftPhB/FtNbTOp1BccMGgxYcFBBDR5CZgTMvDm2AbSADrACrAE9YAC9Ji5mdQJdkKiKlKFHkUngGWvGitExWkbDqBmRsU+LT0lOCKk5zkH+FQPz1yRDiC06TLE1gSGwhxJCRVATeNbe+cBMJqZaLqkdqGi3ZyQqFIbTOXSZlNOs... |
700,911 | Frequency Game | Given an array A of size N. The elements of the array consist of positive integers. You have to find the largest element with minimum frequency.
Examples:
Input:
5
2 2 5 50 1
Output:
50
Explanation :
All elements are having frequency 1 except 2.
50 is the maximum element with minimum frequency.
Input:
4
3 3 5 5
Out... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public static int LargButMinFreq(int arr[], int n)"
],
"initial_code": "// Initial Template for Java\n\nimport java.util.*;\nimport java.io.*;\n\n// Position this line where user code will be pasted.\n\n// Driver class with ma... | {
"class_name": null,
"created_at_timestamp": 1634368837,
"func_sign": [
"LargButMinFreq(arr,n)"
],
"initial_code": "# Initial Template for Python 3\n\nt = int(input())\n\n# Iterating over test cases\nfor _ in range(t):\n n = int(input())\n arr = [int(x) for x in input().split()]\n print(LargButM... | eJztlbtqW0EQhlO4yGMMpzZh7xc/SSAKLmIVaWQXEhiMjR/Cftd0yTfnApHRKIqCu2gZEOx3/rnszO7zxevPjx/G3+cf/PnyMHzf3O22w5UMfrXxTs1JwCKWsIwVrGIN6xiMGy5lWN/frb9t1zfXt7vtosLWavO02gyPl3JQfZJos2SZXaTZZZjkz1aXJf4lhyWPJZdsimdTO7CRZVlpXnFeYV5elxX4EWXPtxG9LEWqNOnkIB4tJKP4JD6LL+Kr+Ca+k5nhJNi1GYuDpEPTIepQdcg6dB3CDmWH49EznPpW5+pd3at/DUAjIAQf4IKG... |
703,229 | Numbers with prime frequencies greater than or equal to k | You are given an array arr. You need to find elements that appear a prime number of times in the array with minimum k frequency (frequency >= k).
Examples:
Input:
arr[] = [11, 11, 11, 23, 11, 37, 51, 37, 37, 51, 51, 51, 51], k = 2
Output:
[37, 51]
Explanation:
11's count is 4, 23 count 1, 37 count 3, 51 count 5. 37 ... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public List<Integer> primeOccurences(int[] nums, int k)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass Main {\n public static void main(String args[]) throws IOException {\n BufferedReader read ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"primeOccurences(self, arr, k)"
],
"initial_code": "if __name__ == '__main__':\n tc = int(input().strip())\n\n while tc > 0:\n arr = list(map(int, input().strip().split())) # Input array\n k = int(input().s... | eJy1VEtuwyAQ7SLqOUasoyqAE9s9SaUQZdF60Q3NwpEiVZVyiOYm2fVyGYNx/JmxjNUwHoEMMzDvPTgvLn/PT669XXGw/Raf9nAsxSsIaawEBbpxbawWSxDF6VC8l8XH/utY1muVseJnCb3olQTvuuVp3/msdQCVew1tS3smZfszVjEbrN3sMHuOLdMwucNamR3CPIWOa/DgHqFi0a0XDM+mQHnGnSXB+FwJWSEPC7kcRpgiafLyTFAAGyQ9gxyLdpQrkCOc0IynMMEr2qKyDrXiexzUCDGCymYoqoHD6z4ehc6NVRE3lS5+08Eu/ydQ... |
700,334 | Dijkstra Algorithm | Given a weighted, undirected and connected graph of V vertices and an adjacency list adj where adj[i] is a list of lists containing two integers where the first integer of each list jdenotes there is edge between i and j,second integers corresponds to the weight of thatedge .You are given the source vertex S and You to... | geeksforgeeks | Medium | {
"class_name": null,
"created_at_timestamp": 1729144616,
"func_sign": [
"ArrayList<Integer> dijkstra(ArrayList<ArrayList<iPair>> adj, int src)"
],
"initial_code": "import java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass iPair {\n int first, second;\n\n iPair(int first, int second) {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1729144616,
"func_sign": [
"dijkstra(self, adj: List[List[Tuple[int, int]]], src: int) -> List[int]"
],
"initial_code": "if __name__ == '__main__':\n test_cases = int(input())\n for cases in range(test_cases):\n V, E = map(int, input().strip... | eJzNVs1u00AQ5sCNlxj5XCHP7o53lydBwogD5MDF9JBKSAjEQ8DrcOO9mG9mYrVCtiqlTZtYcRSv5/uZbzb++fL331cv7PX2j3559234vFzfHIc3NPC8CE3zMhITjzhnknlhSqSXEhUq85L1YsKpUNclwxUNh6/Xh4/Hw6cPX26OUWqkSo2EONG8/JiX4fsV3UWaqDlSxSmhGCseC5Cy4bNiMDuW0ipar+OqgMAecifWo+nNW+gm5aQTAk+woXrcA2A9VNq0VbyFe+wgCUrNRHaNzc2srszMFCxVlRCoPbACokqmPR5FLVaDuYBLypQ2... |
700,463 | Bridge edge in a graph | Given aGraph of V vertices and E edges and another edge(c -d), the task is to find if the given edge is a Bridge.i.e., removing the edge disconnects the graph.
Examples:
Input:
c = 1,
d = 2
Output:
1
Explanation:
From the graph, we can clearly see that
blocking the edge 1-2 will result in
disconnection of the graph... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1616496394,
"func_sign": [
"static int isBridge(int V, ArrayList<ArrayList<Integer>> adj,int c,int d)"
],
"initial_code": "import java.util.*;\nimport java.io.*;\nimport java.lang.*;\n\nclass DriverClass\n{\n public static void main (String[] args) {\... | {
"class_name": "Solution",
"created_at_timestamp": 1616496394,
"func_sign": [
"isBridge(self, V, adj, c, d)"
],
"initial_code": "# Initial Template for Python 3\n\nfrom collections import OrderedDict\nimport sys\n\nsys.setrecursionlimit(10**6)\n\nif __name__ == '__main__':\n t = int(input())\n for ... | eJzNVE1LxDAQ9eDBX+BNePS8SF/S9MNfIhjxoD14iXvogiCKP0L/r5kkLlu2ZZtF0R5KmMy8mXkzee+nnxdnJ+G7PveHm5fi0a03Q3GFgtYZGOtK+BOhrFPQ1mlUYquSrVih6J/X/f3QP9w9bYYUXFr35i9fVxgj1mimEStJxZhPJ5dM7CpWNsIOYOGUCUYPpBJcKXBT9RrUqaUGrXUtOnHuxFmnU2baBDHDz26+Ui5Mus1tzoD1wjzffXVgGWmRIAZ2qEAfSA1G6sNWBL/wzyxLeaL542WxAs22Z9agB2ADegi2YCS8EzxxiP9cQlXI... |
705,618 | Check Mirror in N-ary tree | Given two n-ary trees.Check if they are mirror images of each other or not. You are also given e denoting the number of edges in both trees, and two arrays, A[] and B[]. Each array has2*e space separated values u,v denoting an edge from u to v for the both trees.
Examples:
Input:
n =
3,
e =
2
A[] =
{1, 2, 1, 3}
B[... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1619077929,
"func_sign": [
"static int checkMirrorTree(int n, int e, int[] A, int[] B)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOExceptio... | {
"class_name": "Solution",
"created_at_timestamp": 1619077929,
"func_sign": [
"checkMirrorTree(self, n, e, A, B)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n n, e = map(int, input().split())\n\n A = list(m... | eJzNVcFOwzAM5cCFv7BynlCdpu3KlyAxxAF64FJ26CQkBOIj4Fe48W/YLyurVIIS2k60ipUmfu/ZzuK9nr5/np3gufyQydWTuW+3u85ckOFNa0kMk4UxKzLN47a57Zq7m4ddd3B72bTmeUVhbB7AZgGsoxxYEqi8DhykC/KRGEfh4Z7LkpNRHPjkQxcTOUtP8R2fDJGhchhngQ1ZTOTmjOpRwDIrZVQyW8uoZcbZUK2Cxz4b7MJN3GeVdyLvwPubvHo4BMpZqrxgxuf1o74alnW2anSXkXkRFRh7DiDBoUhwpP7OM+LIigUjFh8u1VTi... |
704,612 | Minimum Notes Required | An employee's wallet can contain no more than M notes or coins. A boss pays his salary by the minimum notes possible. However the employee may have to leave out some money. Find how much money he has to lose if his original salary is N.Note: The values of notes or coins available are 1000, 500, 100, 50, 20, 10, 5, 2 an... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int getLoss(int N, 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 BufferedReade... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"getLoss(self, N, M)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N, M = map(int, input().split())\n ob = Solution()\n p... | eJytk70KwkAQhC30PZarRe5XEys7X0HwxEJT2MQUEQRRfAh9X281gQjOGX+mCsx+d7MT7ty9Tnudu2aT8DE/iE1e7EoxJqF8nrJISZ+LPolsX2SrMlsvt7uymkl4wOenMHDs0zPsrNGKHGRtGnzAJixSGB6ZMABgpY11ZCCbBhugaTIaOtKxe8MAupdFCrJKBh+wmkUaN80+YA2LDGbZB6xlkcUs++gHs8hhlv23+94PqtvjA73XkTMjPTzyyF8CuUYi79pmkrFA8YZku47c/3uqL4DRLE5W7RVf6+uiP625enc/vbqX7TY3bdX04jK4... |
703,119 | Search Pattern (KMP-Algorithm) | Given two strings, one is a text string,txt and the other is a pattern string, pat. The task is to print the indexes of all the occurrences of the pattern string in the text string. Use 1-based indexing while returning the indices.Note:Return an empty list in case of no occurrences of pattern. The driver will print -1 ... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1731402181,
"func_sign": [
"ArrayList<Integer> search(String pat, String txt)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1731402181,
"func_sign": [
"search(self, pat, txt)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n s = input().strip()\n patt = input().strip()\n ob =... | eJzFVdtKxDAQ9cEHP2Po8ypNevdLBCPS27oVmi22C1UR/Aj9Ft/8NjOpxbqb6UUWTNPusKFzzpy59PX0/fPsRK+rD2VcP1uFrHaNdQkWEzJOzFd3Yq3AytsqT5s8u93umv49cMCDACJgDJgDzAMWAIuAMxDSelnBHshgJUMbUSgMDtw1emsfn0Z2f05SdxVxZmvavuasgDwz7SQd2UJ2BgHkgI/6cC1OiMoQ4TR53VB3d0qG4iGCg9qje3MQZVHXuKuqMJtCokFgcIXRKaXY84CSKaNuIb9Nwr8LodZI+bcnSweX/ocUhKvCdBVlX+U4... |
702,833 | Minimum Distinct Ids | Given an array of items, the i'th index element denotes the item id’s and given a number m, the task is to remove m elements such that there should be minimum distinct id’s left. Print the number of distinct id’s.
Examples:
Input:
n = 6
arr[] = {2, 2, 1, 3, 3, 3}
m = 3
Output:
1
Explanation :
Remove 2,2,1
Input:
n = ... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1617823396,
"func_sign": [
"int distinctIds(int arr[], int n, int m)"
],
"initial_code": "//Initial Template for Java\n\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])\n {\n Scanner sc = new Scanner(System.in);\... | {
"class_name": "Solution",
"created_at_timestamp": 1617823396,
"func_sign": [
"distinctIds(self,arr : list, n : int, m : int)"
],
"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 arr = [int(x)... | eJzNVctOwzAQ5MCFP+BWy+cK2U7ctHwJUo04QA5cTA+phISo+hHt/7LY8aNONo1DpZL1IVKS2Z3d2cn+9ji7uzHX0z3crL/ou95sG/pIKFfaHzontP7c1K9N/fbysW3aV5jSO3j4PSfJd/CAE04ERAFRQkgilZYoVJELxVAoiUBVFsliAZrSBYohEIyVwwgVAUiZjcNlLy2ygKgglqZcBLREQEV/rwIoxAqCM2Lamt9C8TtDIj2qQ3boLoPP4k5LOXP4hSEkQqsNpfKkgDh5mpibxALniXVSssAz5hrzjTnHvDvcQy2nRyTHtveqlfJu... |
711,597 | Path With Minimum Effort | You are a hiker preparing for an upcoming hike. You are givenheights[][], a 2D array of sizerows x columns, whereheights[row][col]represents the height of cell(row, col). You are situated in the top-left cell,(0, 0), and you hope to travel to the bottom-right cell,(rows-1, columns-1)(i.e.,0-indexed). You can moveup,dow... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1714068859,
"func_sign": [
"public static int MinimumEffort(int rows, int columns, int[][] heights)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass IntMatrix {\n public static int[][] input(BufferedReader br, int n, int m) throws ... | {
"class_name": "Solution",
"created_at_timestamp": 1714068859,
"func_sign": [
"MinimumEffort(self, rows : int, columns : int, heights : List[List[int]]) -> int"
],
"initial_code": "class IntMatrix:\n\n def __init__(self) -> None:\n pass\n\n def Input(self, n, m):\n matrix = []\n ... | eJzlVs2KwjAQ3oOnfYqQy16KNKlR9EkEu3jY7cFLt4cKgig+hL6vYTZOE5uZ2uJhWdOBhEzyzTd/oafRZfz+BmP5YRervdyU1baWCyFVXk5AlFApjPvZqtyGplW3OaNVt9nakomQxa4qvurie/2zrR2XOYy8PNoTh0SELA2IsiTgy8sWG5wDpYlvR+8gNkFQEdwyEIT0YtDYieqHBGIKogR+TO4C815ITE8FD9sQIfxJCVdmIB7CndXYyp2nCMV5G5L5gzgMk8He/wpdBfy9rhqibmuQSAvTUHiUAfRQ0s765gFdN7VygHsvVGVPK7M+... |
710,141 | Replace every element with the least greater element on its right | Given an array arr[] of N integers and replace every element with the least greater element on its right side in the array. If there are no greater elements on the right side, replace it with -1.
Examples:
Input:
arr[] = {8, 58, 71, 18, 31, 32, 63, 92, 43, 3, 91, 93, 25, 80, 28}
Output:
{18, 63, 80, 25, 32, 43, 80, 93... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1650387689,
"func_sign": [
"public static ArrayList<Integer> findLeastGreater(int n, int[] arr)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\nclass IntArray\n{\n public static int[] input(BufferedReader br, int n) throws IOException\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1650387689,
"func_sign": [
"findLeastGreater(self, n : int, arr : List[int]) -> List[int]"
],
"initial_code": "class IntArray:\n def __init__(self) -> None:\n pass\n\n def Input(self, n):\n arr = [int(i) for i in input().strip().split... | eJztV81uE0EM5sAD8AjWnls09nj+eBIkUnGgOXBZekglJATiIeB9sb9NokI7myZpSVV1M2NNov2+sT2fvZufr39fvnmF6/2FLT58Gz6PV9er4R0NvBglLEZOxIEkUEykZgOlQDmQJpJEKVGxr7agkqgFqmYT1WCgMJzRsPx6tfy0Wl5+/HK9WhML6AR0xqJgybDTomyG0TTwGRnmOdNi/LEYh+9n9I+ryVwNflHzC7bCFtgMm2AVNsIKLMPaJiQUSS2cTIUM78EzEwtxJNZOSObX/JhnnYkr2hEk3FgNrABa5tl4DFqNlovzqfN5Wokz... |
714,215 | Wifi Range | There areN rooms in a straight line in Geekland State University's hostel, you are given a binary string S of length N where S[i] = '1' represents that there is a wifi in i**th room orS[i] = '0'represents no wifi. Each wifi has range X i.e. if there is a wifi in i**th room then its range will go upto X more rooms on it... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1678707319,
"func_sign": [
"boolean wifiRange(int N, String S, int X)"
],
"initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*; \nclass GFG{\n public static void main(String args[]) throws IOException { \n Buffere... | {
"class_name": "Solution",
"created_at_timestamp": 1678707319,
"func_sign": [
"wifiRange(self, N, S, X)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N, X = map(int, input().strip().split())\n S = input()\n... | eJxrYJlazcIABhElQEZ0tVJmXkFpiZKVgpJhTJ6hgkFMHhAp6SgopVYUpCaXpKbE55eWQFUAZeqAkrU6Cli0GeLUZohDm5ECkDAg3TqwPkNy7AM5k3T7TBVMQPoM8DgVl5WmCkYgL+LTistWM4hrQZAMvSBrwZpJdrKhgYIxyM0gDxuS7Ge8CQFPlMTEgEKL9IRAYQoioB+nFwm5GLsWaFrAk8Ow6oshQXEe3vSCMw8STi5EBGUeUWEZO0UPADW0ZUU= |
712,039 | Pattern 21 | Geek is very fond of patterns. Once, his teacher gave him a pattern to solve. He gave Geekan integer n and asked him to build a pattern.
Examples:
Input:
4
Output:
****
* *
* *
****
Constraints:
1<= N <= 20 | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1662635401,
"func_sign": [
"void printSquare(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 Buffer... | {
"class_name": "Solution",
"created_at_timestamp": 1663319519,
"func_sign": [
"printTriangle(self, N)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input().strip())\n ob = Solution()\n ob.pri... | eJzs2r1u1HeDhuEt9kCsKREFJkBIim32JFbakVIkLtJMKIwUKUr0Ht4e1o6BED7MR14l8IT7uhRj+w/4N4/HnttB86///J//+r///o///eXw4+nJ0+vDtxeH+8fTw+Pp6+PpcPficPXzk6vvr69++O6np9cvfv/OjePpzsXFxduvnv/eby/e+v3PvfwjH3zjzh8f4fDr3YtXbtZXx9P5v0fH0+P33bKbj/X847xyK14c8L7Xb93wl7fq4t976z1LLo+n+/fe/+l9w8uP/CpXP9fVW++ht+/nB+f7+Xi6PN/Vl+dvqMtv3nOX33zQ1776... |
713,137 | Minimize number of Students to be removed | N Students of different heights are attending an assembly. The heights of the students are represented by an array H[]. The problem is that if a student has less or equal height than the student standing in front of him, then he/she cannot see the assembly. Find the minimum number of students to be removed such that al... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1671443990,
"func_sign": [
"public int removeStudents(int[] H, int N)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader read =\n new Buffe... | {
"class_name": "Solution",
"created_at_timestamp": 1671443990,
"func_sign": [
"removeStudents(self, H, 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 H = list(map(int, input().split()))... | eJytlM1OhEAMxzm4PkfDeWPofDHjk5iI8aAcvOAe2GQTo/Eh9HWN/yJsZKVE0OnQQJj+ptN2+nr2vjnPunH1scmy66f8odnt2/yScq4aj0mOLBnCV76lvD7s6ru2vr993Lf9Olc1L/j5vKWxcawahqmnEuaOAkUVYRUEF/IQUwIiAlZ2IK+CvAby4oyBWIiDeEiAlJBISSUGhWjgmumPx0xsifECPxGsRBYnh69MDruV5LEuUWAK2E6PZKF5382FRkZOrJvxjBkiXiw2/MoVBiUMUVFUKSqI8qKcKCvKiNL9S3Pb0A9ZzjmtiPDnkphA... |
702,896 | Type of array | You are given an array arr having unique elements. Your task is to return the type of array.Note: The array can be categorized into ascending,descending,descending rotated and ascending rotated followed by:
Examples:
Input:
arr[] = [2, 1, 5, 4, 3]
Output:
3
Explanation:
Descending rotated, rotate 2 times left.
Input... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int maxNtype(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 static v... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"maxNtype(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 ... | eJytlE1OwzAQhVkgzvHkdUGZsWPHnASJIBaQBZvQRSpVQq04BNyXccJPgjppEsUbR3L86c1743m//HRXF+26u5aP+zfzUm93jbmFobL2CCgQQRkIDAuHvKzNBqbab6unpnp+fN013/+7sj7K4WGDISSXW1ZuU8JE4QV4FWIVCGXtQmxXtxUdVmWxxvopBf36RJ7ALMiBcpAHBVABiuAMTMhmF8452IMDuABHWME4sGhm4c2mnXag3UK3+Qkhaf4OvegwsyX+T1kc1iGakhOJ/OW1QJLcXsnrdLCw4xItau2rd5bGG2R13rOlL7dnAxez... |
703,385 | Transform the array | Given an array arr[] containing integers, zero is considered an invalid number, and the rest of the other numbers are valid. If the two nearest valid numbers are equal, then double the value of the first one and make the second number 0. At last, move all the valid numbers on the left.
Examples:
Input:
arr[] = [2, 4, 5... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public ArrayList<Integer> valid(int arr[])"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GfG {\n public static void main(String args[]) throws IOException {\n Bu... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"valid(self,arr)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n arr = list(map(int, input().strip().split()))\n ob = Solution()\n... | eJxrYJkaxM4ABhHeQEZ0tVJmXkFpiZKVgpJhTJ6Bko6CUmpFQWpySWpKfH5pCVTKQCEmry4mT6lWRwFVg6ECLi1AGVyaDBQMSddkiFOTET5NuO0CacNnG06f4dUItI9cGw0IOhavc4mAOA3HhAZYIE4vEwVxJi3iIOmW09p2AwODweSAAXIBuhPgSRndGaQFFwFHI1tBasrAHmy09wpRCkiKU5gDiQgkVEhccsbraNpkZ9wVAw4n41CPbrICuXUBPF0Qqhljp+gBAHxwxvw= |
703,637 | Previous number in one swap | Given a non-negative number N in the form of string. The task is to apply at most one swap operation on the number N so that the result is just a previous possible number.
Examples:
Input:
S = "12435"
Output:
12345
Explanation:
Although the number 12354
will be the largest smaller
number from 12435. But it is
not... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static String previousNumber(String S)"
],
"initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])throws IOException\n {\n Buff... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"previousNumber(ob,S)"
],
"initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n S = str(input())\n\n ob = Solution()\n print(ob.previou... | eJylVEEOgjAQ9OBDSM9otkuB4ktMxHhQDl6QAyQmRuMj9JXefIEFW01IBgQXSJp0dro7s+U6vT+nkyaWD7NYncQ+L6pSLDwh01ySC+F7IjsW2bbMdptDVVrMzIAuaS7OvtfK/MTgTKZAEYVRDDJrAKkaABhYqiAKdUwJYLAAihPEQO5BDHabGHURhHHCKtKIwQFIIwai98uIodk1H6zBmTfCg0AZfTVU0AJIIwVNVW8KxNB7tlv2lCA79BvVO9fOsLFGpul3DrCRAI99tdJ194VnU466jqMnYfhZwxLor98M/zot3B6X9W3+Asf/c78= |
703,464 | Reaching the heights | The teacher gives a mental ability question to Raju. The question is as follows:-
Examples:
Input:
arr[ ] = {2, 3, 4, 5}
Output:
5 2 4 3
Explanation:
Array can be arranged as {5,3,4,2} or
{4,3,5,2} or {4,2,5,3} but it will get
arranged as {5,2,4,3} because he always
prefer to move more number of floors up
and le... | geeksforgeeks | Medium | {
"class_name": "Complete",
"created_at_timestamp": 1615292571,
"func_sign": [
"public static ArrayList<Integer> reaching_height(int n, int arr[])"
],
"initial_code": "//Initial Template for Java\n\n//Initial Template for Java\n/*package whatever //do not write package name here */\n\nimport java.io.*;\ni... | {
"class_name": null,
"created_at_timestamp": 1615292571,
"func_sign": [
"reaching_height(n, arr)"
],
"initial_code": "# Initial Template for Python 3\n\nfor _ in range(0, int(input())):\n n = int(input())\n arr = list(map(int, input().strip().split()))\n ans = reaching_height(n, arr)\n if len... | eJy1VNtKw0AQ7YPQ3xj2uchesm3WjxAfBVcENQ8F2RSagiCKH6H/69mlwbTNpHGJSXZbMmfnzJkz7efF93w+S9ftDF/u3sQ6bHaNuCKhfFASizQZKsjSklZUkiMlxYJE9bqpnprq+aHeNe0JSQpxDZQBtsAJ68OHD+J9QT2ZJcAlgIABbHBQTZAZAUsDN0NxXTd0U2+368eXikm98sFQ587PtIx9VVJCkXNI5UpWeFIepTto5zRrH3SqSdPRJ5PXpPjJYvLjvUUhWPmSYYuWZCB5v3OV/SLwMMmKOD2xNQdbfnGuZ86ZbJh/RDUwBsiC... |
705,822 | Police and Thieves | Given an array of size n such that each element contains either a 'P' for policeman or a 'T' for thief. Find the maximum number of thieves that can be caught by the police.
Keep in mind the following conditions :
Examples:
Input:
N = 5, K = 1
arr[] = {P, T, T, P, T}
Output:
2
Explanation:
Maximum 2 thieves can be
ca... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int catchThieves(char arr[], int n, int k)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*; \n\n//Position this line where user code will be pasted.\nclass GFG{\n public stat... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"catchThieves(self, arr, n, k)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n line1 = list(map(int, input().strip().split()))\n n... | eJxrYJl6lI0BDCL2ARnR1UqZeQWlJUpWCkqGMXmGBgrGMXkhCgFAGKIAo4FYSUdBKbWiIDW5JDUlPr+0BKrFNCZPqVZHAc0QUwWjmDw0A+AYLIbDOHNsxhkZKJjC3AQzAM04BI3DYEMDrCabKhjCHAozEYuZaBiX4w0NsdlhbKBgggiMEBQfYPMHsUFliD3owR7CoQVrGIB14Ao27DoMwFoUMCDphgQoYEASDTGFhC0aJiW1UhhBeGLIhAQ34w4+rKZgT7l0SbpEBA35iReeIElMk2RGYgBhl+KKRETqJTv5kpvyyE16qPbR3UJk+6iT... |
703,668 | Maximum prefix sum for a given range | You are given an array arr of integers and a list of queries. Each query consists of two indices, leftIndex and rightIndex, defining a range in the array. For each query, calculate the maximum prefix sum within the given range.
Examples:
Input:
arr = [-1, 2, 3, -5], leftIndex = [0, 1], rightIndex = [3, 3]
Output:
[4, 5... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1617565437,
"func_sign": [
"public List<Integer> maxPrefixes(List<Integer> arr, List<Integer> leftIndex,\n List<Integer> rightIndex)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n public static void main... | {
"class_name": "Solution",
"created_at_timestamp": 1617565437,
"func_sign": [
"maxPrefixes(self, arr, leftIndex, rightIndex)"
],
"initial_code": "def main():\n import sys\n input = sys.stdin.read\n data = input().splitlines()\n t = int(data[0])\n index = 1\n\n solution = Solution()\n\n ... | eJyVUstuwyAQ7CH9jxXnUBlsjNMv6C3XSiXqofWhF5KDI1WKUvUj2v/N7prg5rERBcRDDLPDzn7Pfpf3d9yen3DzslMfcbMd1CMoE6I2FeCYlhArsIA3DdRQqzmo/nPTvw39++t6O6SHFRA8xK8Q1X4Op5R0yZ22DRE1Mo3AYSpsJIeWvwfiNGARgSoleeOD9FCIoA0Ig2WDC7EDD60QYgJfZXeQ+khmx3QagcwmqJAKTilP4n9lN3RyVx/t5ezJ1macxIaZtexHTXPDW0dzm+xJBqUECGH48cRgZaNOygnPsu23ywm0zTE1B2XVmmSD... |
704,431 | Count ways to N'th Stair(Order does not matter) | There are n stairs, and a person standing at the bottom wants to reach the top. The person can climb either 1 stair or 2 stairs at a time. Count the number of ways, the person can reach the top (order does not matter).Note: Order does not matter means for n = 4:- {1 2 1},{2 1 1},{1 1 2} are considered same.
Examples:
I... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1619084816,
"func_sign": [
"public int nthStair(int n)"
],
"initial_code": "import java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n BufferedReader br = new Buffe... | {
"class_name": "Solution",
"created_at_timestamp": 1619084816,
"func_sign": [
"nthStair(self,n)"
],
"initial_code": "# Initial Template for Python 3\n\nimport sys\nsys.setrecursionlimit(10**6)\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n = int(input())\n o... | eJylmc2OpMURRVnwFKxGvUYoI/Iv0k9iyWMhgWfBpmExSEjIkh/Cfl+fk43FYroaMe4ZekpVlflF3rhx40byry//88NXX9yfv37Hi7/9+vTD808/f3z6y7uneP8crb1/fvr63dOHX3768P3HD//49sefP/728dw9xq4xWvSK3WpEY8nTP79+98kmj3fZrffW194RI7NiVkb1mXMU7/FqnL1bVOQ61VeftXvukauN02arHXPMzuqKs07vcx8+zXH4M1euiN27e802xskRe81zolVFLfbLxfqW2dfY0VaLbLP3PSIjd6/F6hP8nIp+OkfO... |
702,797 | Search in a matrix | Given a matrix mat[][] of size NxM, where every row and column is sorted in increasing order, and a number X is given. The task is to find whether element X is present in the matrix or not.
Examples:
Input:
N = 3, M = 3
mat[][] = 3 30 38
44 52 54
57 60 69
X = 62
Output:
0
Explanation:
62 is not present in the
matr... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1730658707,
"func_sign": [
"public static boolean matSearch(int mat[][], int x)"
],
"initial_code": "import java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass gfg {\n public static void main(String args[]) {\n Scanner sc = new Scanne... | {
"class_name": "Solution",
"created_at_timestamp": 1730658707,
"func_sign": [
"matSearch(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 fo... | eJztltGKE0EQRX0QfNJvOMzzItvd1dXVfsmCERGNIMi4aAKCuOxHrP9r9STu5sEZzSQbBW1C0qRmbt97a6pqrh9+e/L4wbAuHvnm+ZfuXX+5XnXP6MKiD7Qv/3RndMvPl8vXq+Wblx/Wq+0lq4/r5aK/WvTd1zN+duv5Zt3t9geKxAHtFipSN+sQ1ERqqLH9CBld9AXDMesxwcIYtbev3n+atO5O4wyETN4SQtpWGfi4if63w0dCIgihXaaEQjBCJTZ7/T73PBGF2OJpf0MEadodj3SOtFOzg5Ey4pCxECupIObmOUs3sJLb4TPc93MG... |
703,912 | Edit Distance | Given two strings str1 and str2. Return the minimum number of operations required to convert str1 to str2.The possible operations are permitted:
Examples:
Input:
str1 = "geek", srt2 = "gesek"
Output:
1
Explanation:
One operation is required, inserting 's' between two 'e'.
Input:
str1 = "gfg", str2 = "gfg"
Output:
0... | geeksforgeeks | Hard | {
"class_name": "Solution",
"created_at_timestamp": 1731309684,
"func_sign": [
"public int editDistance(String s1, String s2)"
],
"initial_code": "import java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n BufferedRe... | {
"class_name": "Solution",
"created_at_timestamp": 1731309684,
"func_sign": [
"editDistance(self, s1, s2)"
],
"initial_code": "if __name__ == '__main__':\n T = int(input())\n for i in range(T):\n s1 = input()\n s2 = input()\n ob = Solution()\n ans = ob.editDistance(s1, s... | eJztVs1yEzEM5sCVd+jk3GFIQ/94EmYww2htJevprmy0dtuUYYaHgFfgxjsie1OaNHG6pAF6IJNZSU5Wtj59kvzl+bcfL57lz9vvorz7NLLkYxi9ORhNFF3YEJAUdSItzRRNG7hSJA9ZnMU2PWh0eDDCa486oPngYrh7/UjRWNHo8+HBqltL4jVYJ07wGnXs1RYVzV1UFBhFDbWIgu9jRZNNvmVDqLTBqRz1WpR51uBG0Q0UXB3lY97zI549NJYMu3QqbB0bsg34gpPxqzUXr2VfghmDgCQSssJAxuWFXoL3jfivFlJb1tm2ei5K+cTj... |
705,889 | Recursively remove all adjacent duplicates | Given a string s, remove all its adjacent duplicate characters recursively.Note: For some test cases, the resultant string would be an empty string. In that case, the function should return the empty string only.
Examples:
Input:
S = "geeksforgeek"
Output:
"gksforgk"
Explanation:
g(ee)ksforg(ee)k -> gksforgk
Input:... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"String rremove(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 BufferedReader br = ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"rremove(self, S)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n S = input()\n ob = Solution()\n print(ob.rremove(S))\n ... | eJytVEsOgjAQdaH3IF0TE7bewJ1LE2uM/UEBy8eioNF4CL2vrbJCasLorNpM3pt5b6a9jR+LyegVy7k5rM5IqrzSaOahAKstVsj3EK9zTjVnm6zSbdJkriZ58b0Owg1xIQgdXoUQQGuEMs4oBGnqUcoY50KEYRRJOVTkycTWRGPDXga79NFCHA/nsCyWxzJZLssmBGBijIswknGS7lSWF+VeV4djbYQ19fFQ6X1Z5JnapUkso1AAPW+nhTFkXg6hWAAs6zbzu+sg03sUBeT94CAjdKw14C06ze7f+7/pbn8bUwdkgN3JQEH+uC8Q1ULW... |
707,516 | Course Schedule | There are a total of n tasks you have to pick, labelled from 0 to n-1. Some tasks may have prerequisite tasks, for example to pick task 0 you have to first finish tasks 1, which is expressed as a pair: [0, 1]Given the total number of n tasks and a list of prerequisite pairs of size m. Find a ordering of tasks you shoul... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1621263926,
"func_sign": [
"static int[] findOrder(int n, int m, ArrayList<ArrayList<Integer>> prerequisites)"
],
"initial_code": "//Initial template for JAVA\n\nimport java.util.*;\nimport java.io.*;\nimport java.lang.*;\n\nclass Main {\n public stat... | {
"class_name": "Solution",
"created_at_timestamp": 1621263926,
"func_sign": [
"findOrder(self, n, m, prerequisites)"
],
"initial_code": "# Driver Program\n\nimport sys\nsys.setrecursionlimit(10**6)\n\n\ndef check(graph, N, res):\n map = [0]*N\n for i in range(N):\n map[res[i]] = i\n for i... | eJztmN2KHVUQhb3wKbwqznWQXft/+xDqpWCLoDnIgPSEZAKCKD6EPoN3PqPf2n0GhEzizJwzmkDnoijSfb6url6rqqd/+/iPvz75aP776k+Sr38+XK0vXt8cPrNDWtZiZVndwrJG82VNFpc1GweC5WWtVu8+WnQ06Lczizol6ZR51C0entnh+NOL4/c3x+ffXr++OV3x82v74uXz48ur9Qf78vrVq6vvfjwu693/C+3XZT388sz+UTIFeLDxjqqqqmoqvFtb1mFdWVC5/XR0/qzoF6eaq45GndzeUvhWzJ0lufhDBJ+3Lv5EZ6Fni6ou... |
705,824 | Geek in a Maze | Geek is in a maze of size N * M (N rows, M columns). Each cell in the maze is made of either '.' or '#'. An empty cell is represented by '.' and an obstacle is represented by '#'. If Geek starts at cell (R, C), find how many different empty cellshe can pass through while avoiding the obstacles. He can move in any of th... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public static int numberOfCells(int n, int m, int r, int c, int u, int d, char mat[][])"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n//Position this line where user code will be p... | {
"class_name": null,
"created_at_timestamp": 1615292571,
"func_sign": [
"numberOfCells(n, m, r, c, u, d, mat)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n\n for tcs in range(t):\n n, m, r, c, u, d = [int(x) for x in input().split()]\... | eJztWN1KwzAU9sJH8AFCcztCk27CfBLBihe6CxHqkA0EUXwIfV9PTk9Okrl0xrnRSpN2TdPky3d+cnq699PPp7MTLJcP0Lh6Ke6b5XpVXIhC140uBRwzqEaYulFcJNxIJaWyp23bFlTl+7GN16AtbXFA0o+3o3AMthDTIdr+YiKKxfNycbta3N08rlfEsKybN3j4OhExbVMKg8zhqEQVEvcFV1O8SHvT0mEp2x+WY2O2coIyTyetn49ykLSS+zy616efKomYY0gkvY6YWcjFryAj6SJd09MNgVWoCamCdd3wyGYBnoyZoLwyFs2t4VaQ... |
700,217 | BFS of graph | Given aconnected undirected graphrepresented by an adjacency listadj, which is a vector of vectors where eachadj[i]represents the list of vertices connected to vertexi. Perform aBreadth First Traversal (BFS)starting from vertex0, visiting vertices from left to right according tothe adjacency list, and return a list con... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1731499322,
"func_sign": [
"public ArrayList<Integer> bfsOfGraph(int V, ArrayList<ArrayList<Integer>> adj)"
],
"initial_code": "import java.util.*;\n\n// Driver code\nclass GFG {\n public static void main(String[] args) {\n Scanner sc = new Sca... | {
"class_name": "Solution",
"created_at_timestamp": 1731499322,
"func_sign": [
"bfsOfGraph(self, adj: List[List[int]]) -> List[int]"
],
"initial_code": "if __name__ == '__main__':\n T = int(input()) # Number of test cases\n for i in range(T):\n V = int(input()) # Number of vertices\n ... | eJztWMuKXFUUdeA/OF30OMh5P/wSwRIHmoGTMoMOBETwI/QLnfkVrrX3vkmnH2U1SIjQgRRV1fesu/dej3Nu/f7ln39/9YX9+/Yvvvnu15ufz2/e3t58g5t8OufE/+V0Tsh64buMqpd2Ohd0vYzTuWKezg3rdO7Yp/PQx6V3G+nmFW5ev3vz+sfb1z/98Mvb28AmIAo2Kho6BpbW3Pz2Cvfur1ukj+9/bRGqfSJn1aIeNrJWEYrrcrbvcvEvq3/Z4Gvaxap52VG20Hhjlk/0Yjd7pImkKfajDeugqIOqDpo66OrA5jbVQQzPpp8M9al6... |
700,812 | Count Odd Even | Given an array arr[] of positive integers. The task is to return the count of the number of odd and evenelements in the array.
Examples:
Input:
arr[] = [1, 2, 3, 4, 5]
Output:
3 2
Explanation:
There are 3 odd elements (1, 3, 5) and 2 even elements (2 and 4).
Input:
arr[] = [1, 1]
Output:
2 0
Explanation:
There ar... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1617248832,
"func_sign": [
"public int[] countOddEven(int[] arr)"
],
"initial_code": "// Initial Template for Java\n\n// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(... | {
"class_name": "Solution",
"created_at_timestamp": 1617248832,
"func_sign": [
"countOddEven(self, arr)"
],
"initial_code": "if __name__ == \"__main__\":\n # Testcase input\n testcase = int(input())\n\n for _ in range(testcase):\n arr = list(map(int, input().split()))\n\n # Creating... | eJy1VMFKxDAU9CB+x5DzIpmkaapfIljxoD0IS91DFwRR/Aj9X2Oyhc3al7JdNpBOk/ImMy/v9evyZ311EcddF17u39VLv9kO6haKbU+1gureNt3T0D0/vm6H8RN023+2vfpYIY8wQoQGhQjqOI6Ou4njaIGEwcEUOBxcWTKSBORLgc3AiIosHDwCEUELOtCDojUtJx8VajRBEBicVWANNjCF5Ippyi3GZ5PAJ6gTuARVApvAJJDKR87sv7uZnnJqZEMxMuQlJ6OXrr8uivQjQcZmD3cWCN1nPzO9yH5m9aEm41YjHPDXCcWuX9D2WtPu... |
703,807 | Non Repeating Numbers | Given an array A containing 2*N+2 positivenumbers, out of which 2*N numbers exist inpairswhereasthe other two numberoccur exactly once and are distinct. Find the other two numbers. Return in increasing order.
Examples:
Input:
N = 2
arr[] = {1, 2, 3, 2, 1, 4}
Output:
3 4
Explanation:
3 and 4 occur exactly once.
Inpu... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1730658714,
"func_sign": [
"public List<Integer> singleNumber(int[] arr)"
],
"initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.util.*;\nimport java.util.HashMap;\n\n//Position this line where user code will be pasted.\npublic ... | {
"class_name": "Solution",
"created_at_timestamp": 1730658714,
"func_sign": [
"singleNumber(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\n ob = Solution... | eJy9lMFOwzAMhjkgnsPqeUKxkzQJT4JEEQfYgUvhsElICMRDwANx47H4nXWdBvOmbYhJdtss/p04n/N2+vF1dlJ/l594uXpu7vvH+ay5oIa7vu16JiFPgSK1eAox3hLlZkLN9Olxejub3t08zGdDjCOEvHZ98zKhdakMKUcMgUDcEmcSRyIkgaQlyeQdedERL6Z4NsTZqUHeMQw5nIchkYswZHMJlmGFWJfBPMwpZi7V3JjMd72WgLUS7PXJeEmmkDd0YtdLrNuOFByFSNHpJ7yOo+COkjNloyEbaimgoc6rC+qiulZdUpfXp4xjZrpg... |
710,036 | Max Sum without Adjacents 2 | Given an array arrcontaining positive integers. Find the maximum sum that can be formed which has no three consecutive elements present from the array.
Examples:
Input:
arr[] = [1, 2, 3]
Output:
5
Explanation:
All three element present in the array is consecutive, hence we have to consider just two element sum having... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1646227380,
"func_sign": [
"public int findMaxSum(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": 1646227414,
"func_sign": [
"findMaxSum(self,arr)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n # n = int(input())\n arr = list(map(int, input().strip().split()... | eJzFVk1PhEAM9eDFf9Fw3pjpfDDgH9HEVQ/KwQvugU02MRp/hP5f+wAJMdsRcF05dIa00M7r45W304/bs5P2urqUzfVz9lhvtk12QRmvazbGkIVxMB4mwOQwEaaAKWEQbNZ1tqKs2m2q+6Z6uHvaNv3bfOd9lYCXFX1LY50PFLyzTL/Yq7mdK2xkJXmJi5hmrmqyHH6vnbTDE3ACTYAJLAElkASQLY7EiGSEMmIZwYxoRjgjnvEAl32H1HrYRx34rml0oFWvAV6tAa2zp8/iRU0dTYp4Zlz+wTZpHNRqOmYtsmk2OrX9lhx5CpRTpIKE... |
714,125 | Binary matrix having maximum number of 1s | Given a binary matrix (containing only 0 and 1) of order NxN. All rows are sorted already, We need to find the row number with the maximum number of 1s. Also, find the number of 1s in that row.Note:
Examples:
Input:
N=3
mat[3][3] = {0, 0, 1,
0, 1, 1,
0, 0, 0}
Output:
Row number = 1
MaxCount... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1677586163,
"func_sign": [
"public int[] findMaxRow(int mat[][], int N)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nclass FastReader{ \n BufferedReader br; \n StringTokenizer st; \n\n public FastRe... | {
"class_name": "Solution",
"created_at_timestamp": 1677586163,
"func_sign": [
"findMaxRow(self, mat, 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 mat = []\n for i in range(n):\... | eJxrYJlawsYABhG5QEZ0tVJmXkFpiZKVgpJhTB4QGSjpKCilVhSkJpekpsTnl5ZAZQ0UDBRi8upi8pRqdRQwdBni1GWIS5cR0C4FAzBBupVAzYYKhmACp2YjvDYb4rcZv7Px2myI22ZTsD4IBNsPgQSZOJ1piscmJIOItxSnn4i0iXhLcdhkRIZNBCzFYZMxDpsMcGcCdJXEK0VNs0TEDwUhiyNwyMgp5IU4ieENy1RkZ0miXWlAbMLAGSAg3VAbqehOQ/wRilpk4c44JvgKaHIjk9SSHXd+iJ2iBwDubsKz |
704,506 | Nth item through sum | Given two arrays A and B of length L1and L2, we can get a set of sums(add one element from the first and one from second). Find the Nth element in the set considered in sorted order.Note:Set of sums should have unique elements.
Examples:
Input:
L1 = 2, L2 = 2
A = {1, 2}
B = {3, 4}
N = 3
Output:
6
Explanation:
The se... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int nthItem(int L1, int L2, int A[], int B[], 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": [
"ntItem(self, L1, L2, A, B, N)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n L1, L2 = [int(x) for x in input().split()]\n A = in... | eJytVctOwzAQ5IDEb4x8LsjPpOFLkAjiADlwMVWVSiAE4iPgf9ldN0ClLmlJnMiysuvJzGSzfj/9fD47kXG1psX1i3nIq01vLmFcmx14Gm6zgOmeVt1d393fPm76bZ5v8xsFXxfY3ewRBMHSaHOiGTQ5nmhLVPFckg17MSOiYEKYecjV5qCCnTsF6VtaoafL4wQNRF7e0BhUOn7wN5YmbT+WbpOqLLDv5KHggN0kcF56fhjK11BhY1IZJiRhhYDIy4QKNZZo2MXjeVaoxH74QguxVAgqUW9LpDDmmAQlymFdQQiqAsemlKIkbEImXEIl... |
712,184 | Grid Path 2 | You are given a grid of n * m having 0 and 1 respectively, 0 denotes space, and 1 denotes obstacle. Geek is located at the top-left corner (i.e. grid[0][0]) and wants to reach the bottom right corner of the grid. A geek can move either down or right at any point in time. return the total number of ways in which Geek ca... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1667973466,
"func_sign": [
"public int totalWays(int N, int M, int grid[][])"
],
"initial_code": "// Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\nclass GFG {\n public static void main(String args[]) throw... | {
"class_name": "Solution",
"created_at_timestamp": 1667977122,
"func_sign": [
"totalWays(self, n, m, grid)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n n, m = list(map(int, input().split()))\n grid = [list... | eJzdVUtuwjAQ7YJNbzHyGlV2Pk7oSUCAqNRm0U3KIkiVqiIOAffFmdjUjj3UICWqGkv+vvl43nhymJxeHh/wmy/UZPnF3uvtrmHPwNJVnYLqOKjWDqIbcJVAglu4saozyPSRgf6A2wmugbMpsOpzW7021dvmY9doS0rVXmGwT7Fn31OwXFGAHHKjT1zcMeb0orXD7V09lSAtlI0TDtLRa5/0YcQ9SvQ94aErqNsJpcjV45p1219Feo0IhsgIJksoPT1dhlwz7zl5p47eRgGF4VwEiPa0eqfXZWMC1aULlTQzmAWi7lMW4mZ8FHHFnHoR... |
703,228 | Minimum steps to get desired array | Consider an array with all values zero. We can perform the following operations on the array : 1. Incremental operations: Choose 1 element from the array and increment its value by 1. 2. Doubling operation: Double the values of all the elements of an array.Given an integer array arr[]. Return the least possible number ... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int countMinOperations(int[] arr)"
],
"initial_code": "import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"countMinOperations(self, arr)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n tc = int(input()) # Read the number of test cases\n while tc > 0:\n # Read and parse input array\... | eJy9VMtOAzEM5ID4DmvPFYofeSxfgkRRD1AkLksPrYSEkPgI+F+cdBNQG7ecmD3saLOxx/HEH5dfT1cXBbcrJXdvw/O02W2HGxhwOaGrgC4dFjCsXzfrh+36cfWy2847Q1pOw/sCDoIBgUACDMAEQQApAfkAHkljkhjRCHvRxgJIBRALIBSALwApAC4AKgAsMFJpZb1cWWAWmgWrblWvNSQtRokVaewewc8hjhWNpcZiY6Ex35g0xo1RY5Ygwm5THBw9RoD+ybR6pDFujI4tA74t+ro2Mwh7Arz/Yp2sxBNHW3NWFVVXzQthfsf5nWo/... |
700,233 | Postorder from Inorder and Preorder | Given a preOrder and inOrder traversal of a binary treeyour task is to print the postOrder traversal of the tree .You are required to complete the function printPostOrder which prints the node of the tree in post order fashion .You should not read any input from stdin/console.There are multiple test cases. For each tes... | geeksforgeeks | Easy | {
"class_name": "GfG",
"created_at_timestamp": 1730192192,
"func_sign": [
"void printPostOrder(int in[], int pre[])"
],
"initial_code": "import java.util.*;\n\nclass PostOrder {\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n int T = sc.nextInt();\n ... | {
"class_name": null,
"created_at_timestamp": 1730192192,
"func_sign": [
"printPostOrder(inorder, preorder)"
],
"initial_code": "# Driver Program\nif __name__ == '__main__':\n t = int(input())\n for i in range(t):\n n = int(input())\n ino = list(map(int, input().strip().split()))\n ... | eJy1VMtOw0AM5MCBz7ByrtB619tke+MvkAjiAD1wCT20UiUE4iPgf7G92zZIcUpfVSpFu2PP2GPn6/rn7uZKf/czfnl4r167xWpZzaDCtsPYdgQeIiAEmEKCGtBBA+gBEZAAAwgIGUQMGwFVE6jm68X8eTl/eXpbLQuLRDEuKog0wEus4yyJs/EptN1n21UfE/irruYnQ9OGK7Rd4iMVkFNhMIh7IoNgk0WTpA8ZrKXtqhJ+IYp6JRe5AIuSgSkLVpTCPac0iJH/sRB4B57b6yBEIAcUITqI3Hk+4jsGRYXprWAKwFCiYNScXvFR8ZTD... |
705,898 | Theft at World Bank | The worlds most successful thief Albert Spaggiari was planning for his next heist on the world bank. He decides to carry a sack with him, which can carry a maximum weight of c kgs. Inside the world bank there were n large blocks of gold. All the blocks have some profit value associated with them i.e. if he steals i**th... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public double maximumProfit(int N, long C, long w[], long p[])"
],
"initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG\n{\n public static void main(String[]... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"maximumProfit(self, N, C, w, p)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n, C = input().split()\n n = int(n)\n C = ... | eJzNVsFOwzAM5cCFv7B6nqrYibOE/0BCoogD7MClcNgkJATiI+B/eU66A0ibIGUT1bR6dfL8/Gynezv9GM5OynV5AePqubsfHzfr7pw6HkYlds4NYybviCOJI1FSRz5ScBSy+YexW1C3enpc3a5XdzcPm/UEkPts3lcseFnQV2QGkjktAkVKtCRW3FjsgUUTC8Xe4nCgADtZZFCIjSGNuXnZWFMwAoQMtKTGy5KbSEmOU8kuO2OmRoDBQ5jEqIEmPALKEbcK5M2Cj2G18YtF7MoQgPUHdABdrmYADalmLMSLmbHRF1OQQK4IDfFligmL... |
703,264 | Maximum difference Indexes | Given an array arr[] of integers, find the maximum possible gap. The gap is defined as the difference between the indices of an element's first and last appearance in the array. If an element appears only once, its gap is 0.
Examples:
Input:
arr[] = [2, 1, 3, 4, 2, 1, 5, 1, 7]
Output:
6
Explanation:
For the array with... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int maxGap(List<Integer> arr)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\nimport java.util.stream.Collectors;\n\n//Position this line where user code will be pasted.\n\npublic class Main {\n public s... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"maxGap(self, arr)"
],
"initial_code": "if __name__ == \"__main__\":\n t = int(input())\n for _ in range(t):\n arr = list(map(int, input().split()))\n solution = Solution()\n print(solution.maxGap(arr... | eJytVUtOwzAQZYHENUZZN8jjTz6cBIkgFtAFm9BFKyGhIg4Bx2THAZjJJKnzmdBWJI7Hdl/n2W/G9sfl18/VRfPcflPj7i15rje7bXIDiatqBAsOPCAEyCCHgloloKlqAylCVBHWgDUwqZMVJOvXzfpxu356eNltW+dlVb9XdRbVyX4FEbtlj+ybqtCUvksfT23xVWiFCoPGaJ0PGbQmC95Z7MxgsKqDMTIVNqn0DMgM6VH4vfDP0dNg7ybEXrtB6S4ubOTSc5xm3y5czoBvxM0M5AYKA6UIjfQ7cgwJgQRBDgCBkFBIMCz5//SxH8JZ... |
702,088 | Word Search | Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Examples:
Input:
board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output:
1
... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public boolean isWordExist(char[][] board, String word)"
],
"initial_code": "import java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG\n{\n public static void main(String[] args) throws IOException\n {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"isWordExist(self, board, word)"
],
"initial_code": "if __name__ == '__main__':\n T = int(input())\n for tt in range(T):\n n, m = map(int, input().split())\n board = []\n for i in range(n):\n ... | eJzVlUtOwzAQhlmw4hS/sq5Q09eCkyAxCMWJ82o7zaJt0iIkDgF3YMcVcR4yQYaqToOq+osiK5Jn/P8Zj1+v3z9vrqpx/6EmD89Owtlm7dzBcYndIdwhsQcDYgEDYh8GxAEMiCUMiEMYEEcwII5hQJzAgDiFgVIk/ECGUZykzgCOLDLpr2XwtNqsv8U7LwP8tGOKacuMlgUt4S25LZFqmQx88Uey4W/JZpgR76Eh3kFDXEBDnENDvIWGeAONilbk2/3OZhMTTErFQimr5ITK/croFHMsiJdgrJC1DZ0vlrzKbJKMMW5sbSxt7Kyi1o9N... |
704,510 | Subset with sum divisible by k | Given an array arr[] of positive integers and a value k. Return 1 if the sum of any subset(non-empty) of the given array is divisible by k otherwise, return 0.
Examples:
Input:
arr[] = [3, 1, 7, 5] , k=6
Output:
1
Explanation:
If we take the subset {7, 5} then sum will be 12 which is divisible by 6.
Input:
arr[] = [... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int DivisibleByM(int[] arr, int k)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) throws Exception {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"DivisibleByM(self,arr, k)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n arr = list(map(int, input().strip().split()))\n k = int(inp... | eJy1ksFKxEAMhj2Iz/Ez50WSzEyn45MIVjxoD17qIl1YEcWH0Pc1GRGXhbo7pduhobTpn+T783H+9XJxVq7rZ324eXWPw3ozuis47gYmcIREeEIgROoGIbeC67fr/n7sH+6eNuNf+ns3uLcV9jQE3EKCafgGQbohVUq00A6QwQEi8B4xmm6lSlINQYMWrHNwrJ2DCKK3J2NhMKi8rOaBo46SrhTOSMqJ9V8PTuAM0YEzvH7ztcgFwUA18IosgEUtjA0iyzx0hV2BV+gVfITGQrLQWsgWLFnJWmYtWm+KqqLt2uLq3WpdXWLR5ZVUymtW... |
701,297 | Strings Rotations of Each Other | You are given two strings of equal lengths,s1 ands2. The task is to checkifs2is a rotated version of the strings1.
Examples:
Input:
s1 = "geeksforgeeks", s2 = "forgeeksgeeks"
Output:
true
Explanation:
s1 is geeksforgeeks, s2 is forgeeksgeeks. Clearly, s2 is a rotated version of s1 as s2 can be obtained by left-rotat... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1619091325,
"func_sign": [
"public static boolean areRotations(String s1, String s2 )"
],
"initial_code": "import java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\nclass GFG {\n \n\tpublic static void main (String[] args)throws IOException{\n\t\... | {
"class_name": "Solution",
"created_at_timestamp": 1619091325,
"func_sign": [
"areRotations(self,s1,s2)"
],
"initial_code": "# Initial Template for Python 3\nimport atexit\nimport io\nimport sys\n\n_INPUT_LINES = sys.stdin.read().splitlines()\ninput = iter(_INPUT_LINES).__next__\n_OUTPUT_BUFFER = io.Stri... | eJy1VEuOwjAMZTHiHFXWCMGWk4w0RihN0w9Qp7QpXzGaQ8zcd5ICLQhSkVDeIrWSvth+tvPz8Tfv9yp8MmV8HUiCWSnJxCNjQAroA5KBR/g240zyYCZKeT4fAX6rw+PAuyUVNOWX1UAdG6jUZwFgwKi9V03lYRQDxmfT2nsRi1wCLgVGPC9knqD5DmMYNW5tayE03dp7LiSViai/j3YcSqJ1TeaLZaroKLKVEqdcb7a7vZs8vgbTCDS4RqgB2NiP/nQOPu0m+uvOfo/aVx7AVlo1q03KTcJ1si61Arhv5pYuf3VqadvYtt1xejTMDWLO... |
704,716 | Learn Geometry | Find max number of squares (S) of side 2 units that can fit in an Isosceles triangle with a right angle and its shortest side equal to "B" units.Note: The squares don't have to fit completely inside the Triangle.
Examples:
Input:
B
=
1
Output:
0
Explanation:
We can't fit any squares.
Input:
B
=
10
Output:
10
Expl... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static Long maxSquares(Long B)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"maxSquares(self, B)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n B = int(input())\n\n ob = Solution()\n print(ob.maxSqu... | eJytk0FOxDAMRVnAPaqsRyix4yTmJEgUsYAu2JRZdKSREKM5BByPHQchTScVRThBlL+KVOfF/9s9nr99XJwlXb/Hw82zeuy3u0FdNcq0PWe1vdo0qttvu/uhe7h72g25COxUAaST4q1DrH7ZNEuU0Vl1lqe59EcWVVF4YoWMkroCtOR8KBhkTYY9BNCWLEj24kuOLI7fRXeGERwaD8yGAcSe9JxkJaiKOaBaTD5MKDyRBJDPkkHkoq+A1mjLGCAIJMySvWFIcmyTSEopSyaN89AcjGcd5yyB5pbWNlQd2RiyeHk5r1/8K1BqpLY8ad7F... |
703,090 | Convert array into Zig-Zag fashion | Given an arrayarr of distinct elements of sizen, the task is to rearrange the elements of the array in a zig-zag fashion so that the converted array should be in the below form:
Examples:
Input:
n = 7, arr[] = {4, 3, 7, 8, 6, 2, 1}
Output:
1
Explanation:
After modification the array will look like 3 < 7 > 4 < 8 > 2 ... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1672718077,
"func_sign": [
"public static void zigZag(int n, int[] arr)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass IntArray {\n public static int[] input(BufferedReader br, int n) throws IOException {\n String[] s = br... | {
"class_name": "Solution",
"created_at_timestamp": 1672832258,
"func_sign": [
"zigZag(self, n : int, arr : List[int])"
],
"initial_code": "class IntArray:\n\n def __init__(self) -> None:\n pass\n\n def Input(self, n):\n arr = [int(i) for i in input().strip().split()] # array input\n ... | eJzdVc2KFDEQ9uDFt/jo8yKpSlKp+CSCKx50Dl7GPczCgig+hL6hN1/Cr5IR2V0d6N5B1GECc5j+fitdnx5/+fbk0fg8/8ofL94vb/dX14flGRa53Hd+YahoyHAUKGS5wLK7udq9PuzevHp3ffj574+X++XDBW5DSIqDzsfbgCqE2gBT40AgQ0QmiCixRAhJfCNDg69E1RDXAzUMEr8GdAvUHqgeJBacZLIgdqSVHDXFQekoTLChGApTIGRGoQVBScgd2ZGpwpArMkOiRUUW5ATtUIc2KDVUKCNghgoVaEIY8HBAhRFRCQ/UTRNnDP7M... |
707,603 | License Key Formatting | Given a string Sthat consists of only alphanumeric characters and dashes.The string is separated intoN + 1groups byNdashes. Also given an integerK.
Examples:
Input:
S = "5F3Z-2e-9-w", K = 4
Output:
"5F3Z-2E9W"
Explanation:
The string
S
has been split into two
parts, each part has 4 characters. Note that two
extra da... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1621842262,
"func_sign": [
"static String ReFormatString(String S, int K)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG{\n public static void main(String args[])throws IOException\n {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1621842028,
"func_sign": [
"ReFormatString(self,S, K)"
],
"initial_code": "# Initial Template for Python 3\nimport atexit\nimport io\nimport sys\nfrom collections import defaultdict\n\n_INPUT_LINES = sys.stdin.read().splitlines()\ninput = iter(_INPUT_LIN... | eJy1VclSwkAU9ODBL/BmFZUzbbElgDfCJrK6o8ayWMImDKigqKXlR+j/+jKBAjQzIOCbHKjKdDev35KPza+drQ0exW36cfWqNFlv0Ff2XIrXYF6fPwBVC4YQjuioVE3UDOY3mOJ2KeawZ1b6ZvWmO+iPET4/AqqGYCiMiB5FLJ4w2Dtdf3O7ZolL5QqqZg31RrOF23aHodszmCpkjkCPEhuS+6mDNDLZXL4gYAZFCWWQOuJIgJKQsY7vCdjCFAhRIEgBjcJgPiEhXeb3wQHgCFgQR/IihqIj+9dFCI9AKMLN496RdcgXDo9wfHJ6hvPi... |
701,301 | Remove common characters and concatenate | Given two stringss1ands2. Modify both the strings such that all the common characters of s1 and s2 are to be removed and the uncommon characters of s1 and s2 are to be concatenated.Note:If all characters are removedprint-1.
Examples:
Input:
s1 = aacdb
s2 = gafd
Output:
cbgf
Explanation:
The common characters of s1
a... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1619116376,
"func_sign": [
"public static String concatenatedString(String s1,String s2)"
],
"initial_code": "import java.util.*;\nimport java.lang.*;\nimport java.io.*;\n\nclass GFG{\n public static void main(String args[]){\n Scanner in=new S... | {
"class_name": "Solution",
"created_at_timestamp": 1619116376,
"func_sign": [
"concatenatedString(self,s1,s2)"
],
"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 =... | eJydVNsOgjAM9UH/g+xZTXj1S0ycMRsM7xMVvMxo/Aj9Rt/8BrcB3mLLsBBC0p61pzvtuX69N2rWujf90zuQsYzThHQ84lPJ7EuaHhG7WASJCAeLNMn9LR1w0t5j0/tC8YDK3V6BSB1g3RA6LL5/ZTZQAWKN6yfWPJXzMc4DnTIMhYgimK8NK4JA1iIajsaT6WwuF/FytU7SzVa3iTF9BarEX7VwZd/qdDOjkueGUM7sFfgPbUxBGA7M5b+rCxYY2ABKn81DJsOEgfLGoUqW9P6j+WUjyhyvQWVH/WiQ8uFSHWRSJIbOKOoCWfPge8yA... |
701,357 | Minimum Cost of ropes | Given an array arr containing the lengths of the different ropes, we need to connect these ropes to form one rope. The cost to connect two ropes is equal to sum of their lengths. The task is to connect the ropes with minimum cost.
Examples:
Input:
arr[] = [4, 3, 2, 6]
Output:
29
Explanation:
We can connect the rope... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1731573276,
"func_sign": [
"public int minCost(int[] arr)"
],
"initial_code": "\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReade... | {
"class_name": "Solution",
"created_at_timestamp": 1731573276,
"func_sign": [
"minCost(self, arr: List[int]) -> int"
],
"initial_code": "# Initial Template for Python 3\nimport atexit\nimport io\nimport sys\nimport heapq\nfrom collections import defaultdict\n# Contributed by : Nagendra Jha\n\n_INPUT_LINE... | eJzNVE1LAzEQ9SD4Nx45F8nkO/0B3rwLVjzoHrysPWyhIEJ/hP5fk2lF0cy6tSq+XUggycubN5PZHD+fnxwxLs7K5PJB3fXL1aDmULToSc2guvWyuxm62+v71bBb0otePc7wYbNm7HUEkz6BMqURGfinoxjLdllw6ZXjt2aCKuvrYnSCz8gaSSNqBA2v4TSshqmxCoQUbTNEX6QYWDgERCTkUYq2HHz3l1PSzsZWqH8nFVScNCALcqASTABFUALlYofEH5q+ZgYSA5GBwIBnwDFgGTCMIqFCMs1V0uSFCw/z7+fljtRI0rb4Tkly1Rhn... |
703,853 | LCM And GCD | Given two integers a and b, write a function lcmAndGcd() to compute their LCM and GCD. The function takes two integers a and b as input and returns a list containing their LCM and GCD.
Examples:
Input:
a = 5 , b = 10
Output:
10 5
Explanation:
LCM of 5 and 10 is 10, while their GCD is 5.
Input:
a = 14 , b = 8
Output:
... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1730109383,
"func_sign": [
"static Long[] lcmAndGcd(Long a, Long b)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader read = new BufferedRea... | {
"class_name": "Solution",
"created_at_timestamp": 1730109383,
"func_sign": [
"lcmAndGcd(self, a , b)"
],
"initial_code": "# Initial Template for Python 3\n\nimport math\n\nif __name__ == '__main__':\n t = int(input())\n\n for _ in range(t):\n A, B = map(int, input().split())\n\n ob =... | eJylVTtOAzEQpUCcw9o6Qp7/mJMgEUQBKWiWFImEhEAcAs5Cx9kwCZu/vZsw1Ug7fvvmzRv7/fzz++JsEddfObl5aR7b6XzWXIUGxi0gsah5CslNhQmhGYVm8jyd3M8mD3dP81lXTMIeLeYTigoMIY3bt3HbvI7CNmZaBln4yzAVMJefXTX+BrNRgAIoxC461FRHzbE+UkJNjiygQkHMPWel7kVdc0cI0RUBqEwUgY2dlC1ANDKG/I8CKlIUZ4rRgVISBPQhAqzT0qwO1fZKsMpKuu5XVhzgtBiU1aakmHmR2JCmZXjP0tPyakS6HlGp... |
705,701 | Earthquake and the Paint Shop | Geek'sPaint Shop is one of the famous shop in Geekland,but 2014 Earthquake caused disarrangement of the items in his shop. Each item in his shop is a 40-digit alpha numeric code .
Now Chunky wants to retain the reputation of his shop, for that he has to arrange all the distinct items in lexicographical order.
Your task... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"alphanumeric[] sortedStrings(int N, String A[])"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n ... | {
"class_name": null,
"created_at_timestamp": 1615292571,
"func_sign": [
"sortedStrings(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 = []\n for i in rang... | eJztW0mS2jAUzSIHUbHu6sLMZJNrpCpOpRjM2AhsbMCkksohkvtll2tEsgF9tSX5y3QzpN0r2vqSvt4f9Qw/3//++/Fd8vfpD/vw+VtlSldRWPlAKo5Lmy51avVGs9XudKvE33pBGEfT5YpUu512q9mo1xzSWw9H48ls/rRwqfhM6HLlB+sw2myhsFjCpWA5MA8I73eDTZ8uHh5dqnpKlKpZalx5IBVvt/IGoTf8uozCw9nx+xHHakdSs0KJr47HiUv/YGf6/kBkO7bZpv3B0GOTpzPCph/2JWzjXbznYyQd5GO6A4HdgWlWy2kUh4G3... |
703,016 | Form a palindrome | Given a string, find the minimum number of characters to be inserted to convert it to a palindrome.
Examples:
Input:
str = "abcd"
Output:
3
Explanation:
Inserted character marked with bold characters in
dcb
abcd, here we need minimum three characters to make it palindrome.
Input:
str = "aa"
Output:
0
Explanation: ... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1618931138,
"func_sign": [
"static int countMin(String str)"
],
"initial_code": "import java.io.*;\nimport java.util.*; \n\nclass GFG{\n public static void main(String args[]) throws IOException { \n BufferedReader read = new BufferedReader(new... | {
"class_name": "Solution",
"created_at_timestamp": 1618931138,
"func_sign": [
"countMin(self, str)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n\n for _ in range(t):\n Str = input()\n\n solObj = Solution()\n print(solObj... | eJytk1FOhDAQhn3Qe5A+b8yy7mrWk5jIxgxtgQItpbRQMBoPoffVkF0TjcMGYh+aJu3888/0m7fLj7uri3E9rL8Oj89EKO0suQ9IGCkgq4Bwrzm1nD1Vzh6v1pF6jRR5WQW/3sdIQIgEGKCcgpmZRgIDKcZ9tkEazy+KMp6kmciLUqpK16axru18PyBCm920UsLZAhdYNqy1AHFMKWOcJ0maZpkQeV4UZSmlUlWldV0b0zTWOte2Xed93w9Yih1mahh877EuzPXl5hvb7pEkY7MhxHDE6jmF/QMpVKoJRMLbs2izo2DyTQwG+820Fvsp... |
702,719 | Minimum Energy | Given an array containing positive and negative numbers. The array represents checkpoints from one end to the other end of the street. Positive and negative values represent the amount of energy at that checkpoint. Positive numbers increase the energy and negative numbers decrease. Find the minimum initial energy requi... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1617732763,
"func_sign": [
"public int minEnergy(int a[])"
],
"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.parseInt(s... | {
"class_name": "Solution",
"created_at_timestamp": 1617732763,
"func_sign": [
"minEnergy(self, arr)"
],
"initial_code": "# Initial Template for Python 3\ndef main():\n T = int(input())\n\n while T > 0:\n # Convert input to list of integers\n a = list(map(int, input().strip().split()))... | eJyVVLtOxDAQpID/GLm+RV4/EocvQeIQBaSgCVfkJCSExEdAT8dvss7dCQG2Y8fJZi1lx5uZsd/OP74uzpbr+lOSmxf1OO32s7qC4u3EIAMLYhiQhQM5eJBHB+rQg3oEUMAAGsBabaDG5914P48Pd0/7+QhktpN63eAPtNZaqoZYF7Ml5tMMNKegj1V1IwesdQYbhTtLAafBvPRp/OGpnBTI8OmWbRRMZGILI11akVA0DEK8czkknwJy0QohGoC1pD+DOMCYDFafgtILWyi8Gr0kRpVgY+IkRMaok9DHJEgYsrS5NG0n9/kT3Oqs5NOU... |
704,788 | The Palindrome Pattern | Given a two-dimensional integer array arr of dimensions n x n, consisting solely of zeros and ones, identify the row or column (using 0-based indexing) where all elements form a palindrome. If multiple palindromes are identified, prioritize the palindromes found in rows over those in columns. Within rows or columns, th... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public String pattern(int[][] arr)"
],
"initial_code": "// Initial Template for Java\n\n// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws I... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"pattern(self, arr)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n ob = Solution()\n t = int(input())\n for _ in range(t):\n n = int(input())\n L = list(map(int, inpu... | eJxrYJn6jY0BDCLeAxnR1UqZeQWlJUpWCkqGMXmmMXmGCgZAaAjGCBIG0cWAtJKOglJqRUFqcklqSnx+aQnMNIWgmLy6mDylWh0FVEtMYvIQBsEMNUQ2GoeRBjiNNIMYiepuAzSXI6xDtRJZ1hCH1UYKzjisNke12gDNcuwy2ByGLTygKkkODwtYPCLHm6ECeiwiO8FAAdnJaHGMphbdNCzpg2QngxDJmoxA/iQvyRjBUyEOrbqG+Cw1wJNYcOo0huhEiWlyAgqUgwi6gigTSNOLK6iIzuMUZXKYs1F9AErqZKQcJBMQyQiecygO2Rho... |
701,428 | Longest Increasing Subsequence | Given an array a[ ] of n integers, find the Length of the Longest Strictly Increasing Subsequence.
Examples:
Input:
n = 6, a[ ] = {5,8,3,7,9,1}
Output:
3
Explanation:
There are more than one
LIS
in this array.
One such Longest increasing subsequence is {5,7,9}.
Input:
n = 16, a[ ] = {0,8,4,12,2,10,6,14,1,9,5,13,... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1730923336,
"func_sign": [
"static int longestSubsequence(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 BufferedRead... | {
"class_name": "Solution",
"created_at_timestamp": 1730923336,
"func_sign": [
"longestSubsequence(self, arr)"
],
"initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n for _ in range(int(input())):\n a = [int(x) for x in input().split()]\n ob = Solution()\n ... | eJylVD0PgjAUdNAf4OZ46UxMW/ko/hITMQ7K4IIMkJgYE3+E/l8fVAahBYqvwzFwj7t3fTzn79ViVtduSQ/7O7tkeVmwLZhIMgGJDXwECBFBIYbgzANLb3l6KtLz8VoWzds8ydjDQ6sBJ44ibkg9fOolIWwNTPwAneNCd/qW4HVNoCCuS4PSEGkINbipNkwdA+p65Q2gizaO5thmK000SXZCslIZIW8B+Yot/KDDtwk0qHPzMi2U/j1Q4xKVf0b6vW4TrpwxHxJTL+uEaO1/hBEb8zvYlhVUXhB35blvlGlqY+Z0eK0/fERlKw== |
703,648 | Another Matrix Game | Given a string S which contains only small letters. The task is to make a square matrix from string S. Then perform the following operations.1. In each column delete the characters which occur more than one.2. Let the characters in order be abcd....wxyz then print them in order azbycxdw.... For example, after operation... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static String matrixGame(String S)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nimport java.lang.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"matrixGame(self, S)"
],
"initial_code": "# Initial Template for Python 3\n\nimport math\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n S = input()\n\n ob = Solution()\n print... | eJzVVtuK1EAQ9UF80n9Y5nkRffVLBEek7/f7PaL4Efq/9u4Ku8pmnGQHwYakk1Qndaqrzql8e/7j1ctnt+P9i3nx4fNBWF/y4d3V4e3RAogwoYwLqbSx7vTt0R6urw6ke4IywZ9cyb8+xKTBXFkitKPSAKYs5NohcbRf5ztfrq9OOvUhplxq62MZvdWSUwzeWaOVFJxRghEEq66B4N61CrlwvjbEpA2lY6pMzGOh2KgcB0NWltBX0Cw7xiqcN2shAwgRwpgQShnjXAgpldLaGGud8z6EGFPKuZRaW+t9jBNOQMWROwUqSdxp2EgSfk40... |
705,117 | Grouping Of Numbers | One day Jim came across array arr[] of N numbers. He decided to divide these N numbers into different groups. Each group contains numbers in which sum of any two numbers should not be divisible by an integer K. Print the size of the group containing maximum numbers.There will be atleast one number which is not divisibl... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int maxGroupSize(int[] arr, int N, int K)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader read =\n ne... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"maxGroupSize(self, arr, N, K)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N, K = map(int, input().split())\n arr = list(map(i... | eJydk8FKxTAQRV2I7vyGS9cPySSdJvVLBCsutAs38S364IEofoT+rze1oEXS17SFkrbMnZtzJx/nX1cXZ+N1e8nF3Wv1HPeHobpBJV0UWD6qHar+uO8fh/7p4eUw/P5/72L1tsO8SKFdNJjuwmKHuos1AsQWVoqBmNEyKAJFA0+dll8zSk1GiYVd9JAalmoBTlGXumkmMy3tUAE+U+8y9R4uwWiSfwtRSKCbQhNhjI/dlSgoJBBHrUKVVNhFS6zkSrAkS0JkS7iJbg6vzQWlsCaNiSVXiimCph0SM7W9ouWrgTNQA2/QluZX1kA3dPiP... |
703,831 | Reverse Bits | Given a number x, reverse its binary form and return the answer in decimal.
Examples:
Input:
x =
1
Output:
2147483648
Explanation:
Binary of 1 in 32 bits representation-
00000000000000000000000000000001
Reversing the binary form we get,
10000000000000000000000000000000,
whose decimal value is 2147483648.
Input:
x ... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static Long reversedBits(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 BufferedRead... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"reversedBits(self, x)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n X = int(input())\n\n ob = Solution()\n print(ob.reve... | eJyllMFOwzAMhjkgnmPqeUKO7cQOT4JEEQfYgUvZYZOQ0CYeAt6JG6+E244CXR0Yq6oobePf9p8vfT59fT876a7LN5tcPVX3zXK9qi5mFdSN3aFuqvmsWjwuF7erxd3Nw3q1+15t5rNvy7FuMMZ2SG4Io2jIAGrC27pRUk2g3XykRnVDKMm+pRjJFAMFEHSVd6u2Q5jNQiLlKXF7GQBtRGBbypAt1Arz5RGyhIi9rAVF6ZNFZNQ+GyYMPJkudEY6yuBE+L5bGmGlxJPGtaEgJBy07dDTcEIHbSnsYeacxEYvPVOw7ZAU/fSaiEKI5HWP... |
712,068 | Largest odd number in string | Given a string S, representing a large integer. Return thelargest-valued oddinteger (as a string) that is substring of the given string S.
Examples:
Input:
s = "504"
Output:
"5"
Explanation:
The only subtring "5" is odd number.
Input:
s = "2042"
Output:
""
Explanation:
All the possible non-empty substring have even v... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1662723966,
"func_sign": [
"String maxOdd(String s)"
],
"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 Buffer... | {
"class_name": "Solution",
"created_at_timestamp": 1663738757,
"func_sign": [
"maxOdd(self, s)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n s = input()\n ob = Solution()\n print(ob.maxOdd(s))\n ... | eJxrYJn6n4sBDCJ+ABnR1UqZeQWlJUpWCkqGMXkGaEBJR0EptaIgNbkkNSU+v7QEqjImry4mT6lWRwG/bvwAqAGH8SSbQ7FrcDoFh9mGxqbmljg1QWWpEEbIwJhK4YVmJpVdCQSmNHAoxFjsbiU58oyMTUzNzC0sceuEK6Fu+FA9ZHCFiZGJmQXJ4QI2EZG4cViJ3wtEZ0aEI7FbQ3IGJiFs6eFIYt1PG4eT5ARiNJCacgddEMPsGQxhPRDhTLorEarp4WusgjQMCtLdT4wGsgp4chowVKijMcTIqpyo0frC6jxaNCHg9WXsFD0AP6yo... |
702,680 | Palindrome Array | Given an array arr, the task is to find whether the arr ispalindrome or not.If thearris palindrome then returntrueelse return false.
Examples:
Input:
arr = [1, 2, 3, 2, 1]
Output:
true
Explanation:
Here we can see we have [1, 2, 3, 2, 1] if we reverse it we can find [1, 2, 3, 2, 1] which is the same as before. So, t... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1617362265,
"func_sign": [
"public static boolean isPerfect(int[] arr)"
],
"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 IOExc... | {
"class_name": "Solution",
"created_at_timestamp": 1617362265,
"func_sign": [
"isPerfect(self, arr : List[int]) -> bool"
],
"initial_code": "if __name__ == \"__main__\":\n t = int(input())\n for _ in range(t):\n arr = list(map(int, input().strip().split()))\n obj = Solution()\n ... | eJylU9sKgkAQ7aH+47DPEa7rqttLvxFkRJRBECalEETQR9T/Nt4qK6nJWXcdVs+Z3Zkz5+511OvkNvbJmRzFOorTRAwhZBBJ2DSk6EOEhzhcJOFytk2T8odkl4ZBJE591FEGPjyaplgb0Kv5Zv8RruFAZWFpKvI1M7y0YFtQ+UOOtJh4BU0Hzw6vodixK4OpDI9NLhtqg4u2laNdzzcwvudqR9nEUe2xT1LWAvfqMBk0XMqoRyu7nvntixTUxfVJLPTlr2S9iuZHITSq+IXQyIqyfLcgtkwuJvLdP3qjXXOYLP/8npbPMdEUtBmOt4u3... |
703,337 | Maximize the sum of selected numbers from a sorted array to make it empty | Given a array of N numbers, we need to maximize the sum of selected numbers. At each step, you need to select a number Ai, delete one occurrence ofAi-1 (if exists), and Aieach from the array. Repeat these steps until the array gets empty. The problem is to maximize the sum of the selected numbers.
Examples:
Input:
arr[... | geeksforgeeks | Medium | {
"class_name": "Complete",
"created_at_timestamp": 1615292571,
"func_sign": [
"public static int maximizeSum(int arr[], int n)"
],
"initial_code": "//Initial Template for Java\n\n//Initial Template for Java\n/*package whatever //do not write package name here */\n\nimport java.io.*;\nimport java.util.*;\... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"maximizeSum(self,arr, n)"
],
"initial_code": "# Initial Template for Python 3\nfor _ in range(0, int(input())):\n n = int(input())\n arr = list(map(int, input().strip().split()))\n arr.sort()\n ob = Solution()\n ... | eJzt1s1uEzEQB3AOHHkIay9cKuSxPeMxT4JEEAfIgUvoIZWQEFUfAt4X+7/2lnzMKkQ5IepfpEptxjPjtddPL3+9fvUCP+9c/eX99+nL7v5hP711E2125NvHVQVD+8jTnZu23+63n/bbzx+/Puz7Vzhudo+b3fTjzh0F4s2OnWBkhJgDtuA0BCOqeiNq8O3jqIBCHsQRO0oQIWAWjzqsCkjMyWoJ9et1hDoiRuqDHffSRnFz11De31YVW9PZdemkhjAqoV7PWCHF/Lnmwcgq1jzrP1iVprLS1uMquY/nBZyrNIKLGLH5IHY6if0cXZcH... |
703,483 | Average Count Array | Given an array arr[] and an integer x. You have to calculate the average for each element arr[i] and x and find out whether that number exists in the array. Do it for all the elements of the array and store the count result in another array for each index how many occurrences of average are present in the array.
Exampl... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1617554266,
"func_sign": [
"public ArrayList<Integer> countArray(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\nc... | {
"class_name": "Solution",
"created_at_timestamp": 1617554266,
"func_sign": [
"countArray(self, arr, x)"
],
"initial_code": "if __name__ == \"__main__\":\n t = int(input())\n while t > 0:\n arr = list(map(int, input().split()))\n k = int(input())\n ob = Solution()\n res ... | eJy9VTsOwjAMZUDiGlZmhNw/5SRIFDFAB5bCUCQkBOIQcBo2ToYTKEWA66Z8Ysttk/oldp6Tfft47rRMG57oZbRR82y5ytUAlJNkWlUXVLpeptM8nU0Wq7wc3SWZ2nbhyQXuwjuHcBcOBnXjEZDzK1xt/YwTxLoZ2zc2MjYUQB8iZnLiggc+BBRwBIQMjg5NhAMRmFZMeBHhBoTv0TzUG3yM60ItoR+ZqVyEpirzqlokAkBNqUOUBh+0PXara5oPM+cfsxJf67WsF8sKLFj1QjNTjc/9PPUcyrek+LabL7LQqsrQssoe45KCIzRG8fr8... |
704,158 | Modify array to maximize sum of adjacent differences | Given an array arr of size N, the task is to modify values of this array in such a way that the sum of absolute differences between two consecutive elements is maximized. If the value of an array element is X, then we can change it to either 1 or X. Find the maximum possible value of the sum of absolute differences bet... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int maximumDifferenceSum(int arr[], int N)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nclass GfG\n{\n public static void main(String args[])\n {\n Scanner sc =... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"maximumDifferenceSum(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... | eJzVVb1OwzAYZGDiKU6ZK+Tvx7HNysYTIFHEAB1YSodWQkJIPAS8L19CgFaymwZCAUuuklZ3vrtevjwdvpwdHbTr/NQuLh6q2/litaxOUNF0Tq7ZICTb0XawXYOqCarZ/WJ2vZzdXN2tlh2iNkj1OMEmCTckINcu/NhVQRPFZCtmlZFv7HUcu3yWzpBY5/h965whUHjLLViGlqSRGRuDBKQgD7JILVkLOIEd2DAMFrCCPbgGB3AEJ4iDEMQoBaIQD6khARIhCeqgBGWonahQD62hARqhCb4on10+Hmf6jcP0m9gPH//yvmCdG4sZ5635... |
706,386 | Division without using multiplication, division and mod operator | Given two integers dividendand divisor. Find the quotient after dividing the dividendby divisorwithout using multiplication, division and mod operator.
Examples:
Input:
dividend = 10, divisor= 3
Output:
3
Exaplanation:
10/3 gives quotient as 3 and remainder as 1.
Input:
dividend = 43, divisor = -8
Output:
-5
Expla... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public static long divide(long dividend, long divisor)"
],
"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... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"divide(self, dividend, divisor)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input())\n for _ in range(0, t):\n inp = list(map(int, input().split()))\n\n a ... | eJxrYJm6g4UBDCI2AhnR1UqZeQWlJUpWCkqGMXkGCoZKOgpKqRUFqcklqSnx+aUlUEmDmLy6mDylWh0FVB2GOHUY4tChi1uLLi49hgq6JOvRxaMJlx4jQxNzEwtjMxNznG5EKMFlL1yFBW4HINQQYQpOrxM0Bck/SIpJjGJkpyAMJCk6CFuOrgGXn3HEM/50RYzPgGYQG3mGlsYmZmaWlngSOCTJkpFo0cIaf2Bj9RfUI0QGIMRCnEkFSFgQHWeYRhEb2WhBj9vC2Cl6AEfdYAU= |
704,867 | Choose and Swap | You are given a string str of lower case english alphabets. You can choose any two characters in the string and replace all the occurences of the first character with the second character and replace all the occurences of the second character with the first character. Your aim is to find the lexicographically smallest ... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1616271268,
"func_sign": [
"String chooseandswap(String str)"
],
"initial_code": "// Initial Template for Java\n\n// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOE... | {
"class_name": "Solution",
"created_at_timestamp": 1616271268,
"func_sign": [
"chooseandswap(self, str)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n ob = Solution()\n t = int(input())\n for _ in range(t):\n A = input()\n ans = ob.chooseandswa... | eJyNk91OwyAYhj3Q+2g4Xkw49TY8MYoxFNjW/dBuowwwGi9C71eg1ewnL1uTlibf+/D95P2+bn+e727y8/QYf17eSaO73pCHilCmOZlURLlOCaPkW9ubMcSZ/mSafEyqE31AQEBELaRCUIoBLni3t4CzMYbzcRFfOZ4w85GqVPt0Nm8Wy9Vat91muzO93TsPpwAB1GVusze77aZr9Xq1XDTz2VRJgSvniIAT4XUthJTwwiEMaOddcMEHD/D/OORji6GAD2FAl+2jL/mn5FiaBGhmOW+RTgKNJn7B9xQZLlO62C9HDQ/LxHxxcxhLKj6K... |
703,246 | Even and odd elements at even and odd positions | Given an array arr[], the task is to arrange the array such that odd elements occupy the odd positions and even elements occupy the even positions. The order of elements must remain the same. Consider zero-based indexing. After printing according to conditions, if remaining, print the remaining elements as it is.
Examp... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public static ArrayList<Integer> arrangeOddAndEven(int arr[])"
],
"initial_code": "// Initial Template for Java\n\n/*package whatever //do not write package name here */\n\nimport java.io.*;\nimport java.util.*;\n\n//Position ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"arrangeOddAndEven(self, arr)"
],
"initial_code": "if __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n arr = list(map(int, input().strip().split()))\n ob = Solution()\n ans = ob.arrangeOd... | eJydVMtKxEAQ9KD/0cx5kfS8MvFLBCMeNAcvcQ9ZWBCX/Qj9O2/+iJ2eRFRSk9U0AyFTVVPTjxzP3z4uzvS5fpeXm2fz2G93g7kiw21vyZkNmW6/7e6H7uHuaTdMm7LT9oe2Ny8b+slh8oDjiQHHkqdIibiCx80AeKqjQDU1QOBrHzoQ34KJgkqC44oaYvnK0BEiQIdz2DkK0r8W1Bx1nISXCBJRopZIEg3MRlZ1egGvrKC8pKspZGkqw5zN0/PTFDJTCSIK2tJqGSuBpEnWC9BCr2EsiVOzUWC1wAuqYVLlGbqoStpoq51WbrUlY2Nu... |
705,291 | Word Break - Part 2 | Given a string s and a dictionary of words dict of length n, add spaces in s to construct a sentence where each word is a valid dictionary word. Each dictionary word can be used more than once. Return all such possible sentences.
Examples:
Input:
s = "catsanddog", n = 5
dict = {"cats", "cat", "and", "sand", "dog"}
Ou... | geeksforgeeks | Hard | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static List<String> wordBreak(int n, List<String> dict, String s)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nimport java.util.stream.*;\n\nclass GFG{\n public static void mai... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"wordBreak(self, n, dict, s)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n n = int(input())\n dicti = input().split()\n s... | eJzVnNFuG0UUhrngQUa5aiSEKBVccI/EIyBhhMaJSaum65I4ahEC8RDwvtjr3fGc75u1d0uFRAOJz/GZ//z/N75c+c9P/+6++6T/9/3d/sUPv1296t4+7a6+SVfPV91Xq+4m7x7T/lfK3W16PPy63d4d2/ti//rqs3S1ef92c7Pb3P60fdoNp58dzozz1896mbFadX+suqvfP0sLt00u+/bN292vE5I553T4r3+Vp9zuBw4/18cXx79j3Zfj28O7/ZsTOb5ede+2D7dp/bDJr9Ph5fHV24ft+n7zJj1u7592r7bdcax/b3hryl0lN0xe... |
703,022 | Smallest subarray with all occurrences of a most frequent element | Given an array arr[]. Let x be an element in the array with the maximum frequency. The task is to find the smallest sub-segment of the array which also has x as the maximum frequency element.
Examples:
Input:
arr[] = [1, 2, 2, 3, 1]
Output:
[2, 2]
Explanation:
Note that there are two elements that appear two times, ... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1618075590,
"func_sign": [
"public int[] smallestSubsegment(int arr[])"
],
"initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass GFG {\n... | {
"class_name": "Solution",
"created_at_timestamp": 1618075590,
"func_sign": [
"smallestSubsegment(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()... | eJzNVUtOw0AMZcGGW1hZV6jzn3ASJIpYQBdsQhetBEKgHgLui+2ZCW2Jk2lZQOx8mvoX28/enn9uL874uH7Bh5vX5rFbbdbNFTRq0Skg0kyGyTI5okXXzKBZPq+W9+vlw93TZl0USWvRvaPA2wwOLM4BWRc2c7DMbo9F04digz58ig88U8gUmdpEooMsLUbPB7R8lFt5u/dvLLf8Vs7Wb2wORmkw/yZXzPa5CPnJyMndlxypINcQUi3JB94cXTznmd+PfG+l/qD3VL+kqdQOa2bDbHuWo/jWlb6TM2hzRmL2qoobtI4he1ABFIbcckOj... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.