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 |
|---|---|---|---|---|---|---|---|
705,422 | Number of Rectangles in a Circle | Given a circular sheet of radius, r. Find the total number of rectangles with integral length and width that can be cut from the sheet that can fit on the circle, one at a time.
Examples:
Input:
r
=1
Output:
1
Explanation:
Only 1 rectangle of dimensions 1x1.
Input:
r
=2
Output:
8
Explanation:
The 8 possible recta... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int rectanglesInCircle(int r)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"rectanglesInCircle(self,r)"
],
"initial_code": "# Initial Template for Python\n\nimport math\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n ob = Solution()\n ... | eJylksEKwjAQRD30Q0rORbJJN5v6JYIVD9qDl9pDC0JRxG/Q/7U0qeBhCmppIVBeZmZnb8nznizGZ90Ph02vjnXTtWqVKiprq7JUVeem2rfVYXfq2vjLmLK+lrW6ZOknwABwBQBII4kiB4hBCBlyyBdiRBjpkEaQJaMFusP22DA2CB363HqkJjAYiWOXo56GbDicLdgjn4jSSCh+EkRxTMsoY5jOzFzRSGfb8Np5WOFomuKc5lyTcUxogVgH9/Ge2RDiBVykf1z5afKBl5jmnxa+buD9arxuE7t9LF896WLf |
702,736 | Maximum AND Value | You are given an array arr[] of positive integers. Your task is to find the maximum value that can be obtained by performing a bitwise AND operation on any two different elements in the array.Note: AND refers to the bitwise '&' operator.
Examples:
Input:
arr[] = [4, 8, 12, 16]
Output:
8
Explanation:
The pair {8, 12} ... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int findMaxAnd(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 = scanner.nextInt... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"findMaxAnd(self, arr)"
],
"initial_code": "def main():\n t = int(input())\n for _ in range(t):\n arr = list(map(int, input().split()))\n solution = Solution()\n print(solution.findMaxAnd(arr))\n ... | eJytlEFOAzEMRVkgzvE16wrFTuxkOAkSRSygCzZDF62EhEAcAm7FjgvhZEoFUt3Slr/JRDN5iv+35/X0/fPspOnywx6unrr7Yb5cdBfoaDpQSEWyQDhxyWBlShEUKWTqJuhmj/PZ7WJ2d/OwXKxOjZ9Oh5fp0D1P8JsXOWsBaSwJhXpGCr06oOAwCHYMlYLI0ATiAhaFEO+JUpEo2HgpsJUOCpwcZjvlcPsmSKiyu7WF2gqti8NMUnJJXt0tCx2zKGMWaczCbLBKdKxkTw/Gq5Yq5CpoFaQKqQqxyuFqia4PvgGIdQcS2zlg5j5m9cgW... |
711,654 | Pattern 3 | Geek is very fond of patterns. Once, his teacher gave him apattern to solve. He gave Geekan integer n and asked him to build a pattern.
Examples:
Input:
5
Output:
1
1 2
1 23
1 234
1 2 3 4 5
Input:
3
Output:
1
1 2
1 23
Constraints:
1<=
n
<= 100 | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1662576775,
"func_sign": [
"void printTriangle(int n)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass Main {\n // Driver code\n public static void main(String[] args) throws Exception {\n BufferedReader br =\n new Buff... | {
"class_name": "Solution",
"created_at_timestamp": 1663240280,
"func_sign": [
"printTriangle(self, N)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n ob = Solution()\n ob.printTriang... | eJzs3cuu3sixsOke9IUU1NMaMCMzefCVNNACPLBr4IlcgzKwAcPGfy99mT1pybJ+ndbi+g48JMlnsL1PqtJHZsT7BpkRyf/1f/7f/9f/9//+H//PP9/97cPv//jj3Z9+eZfef0jvfv3l3W//8/tvf/njt7/++e//+OPL/+uX9x/+/f7Du3/9+sv3/0DM/APpl3jtH0vdm//cp//M//u/l2/+p/rd/9z/8L8NP/3v4wv/l+nF/1vqXvvBteEf/OL/OaWZ/0+K+f9nym/+/1O55Y+kHy/9tT+Vfr4rr/7B9NIde/3Pppdv58wfT6/e7Jl/... |
703,317 | Digits in a set | Given a numbern, count the numbers from1ton,which comprise only digitsfromset {1, 2, 3, 4,5}.
Examples:
Input:
n = 20
Output:
10
Explanation:
The numbers whose digits are from the given set are: 1, 2, 3, 4, 5, 11, 12, 13, 14, 15.
Input:
n = 100
Output:
30
Constraints:
1 ≤ n ≤ 10**5 | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int countNumbers(int n)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\npublic class GFG {\n\n public static void main(String[] args) throws Exception {\n Buffere... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"countNumbers(self, n)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n n = int(input())\n ob = Solution()\n ans = ob.countNumbe... | eJydkzELwjAUhB36Q0rmInlJn2n8JYIVB+3gEjtUEERxdxP9v5q2CqKXYt5UCF/v3eVyTu7XZNTO7PL8mB/ExtW7RkxTQaVjKbJUVPu6WjXVerndNf2Z4tKdSieOWfpJGAaEloBgiUQIMtZaxDDaLNeKAMTFBECkdI4cWYOkOKClDRF2BX1pK5EaST//c4WfCLk+FXhrKJRQOxS6gI4ayBTSnnknBGmrwzt3pg1HrVCEYibLsOM+5PZ5vH6CexhaP2LlL+UIaV/nttCc//Si1UB9FrfxA9x3Zvc= |
706,298 | Number of Provinces | Given an undirectedgraph with V vertices. We say two vertices u and v belong to a single province if there is a path from u to v or v to u. Your task is to find the number of provinces.Note: A province is a group of directly or indirectly connected cities and no other cities outside of the group.
Examples:
Input:
[
... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1616347539,
"func_sign": [
"static int numProvinces(ArrayList<ArrayList<Integer>> adj, int V)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedRea... | {
"class_name": "Solution",
"created_at_timestamp": 1616347539,
"func_sign": [
"numProvinces(self, adj, V)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n V = int(input())\n adj = []\n\n for i in range(... | eJztV0tOw0AMZcEJOACKIrGrkN1SQJwEiSAW0AWb0EUqISEQh4D7EvKZeGae51MhIUrbRp2xX54dj+2ZvB9+nhwddJ/r43Zw81I+1utNU14VJVf1sqq54ILaL09DqupO8j2dhh1gmJSzolw9r1f3zerh7mnTTIxvVV2+zgrbzHl/qzHUD7k3NQ4HY0JDRmNsh6zPFetM090jB43GbIURsiu0sSYwjsIWsiskKVRcMhPfkEArIThTQnAhFrfnNMsOHhBMzcpLz9l3T3NsoTh2KTPDsiZiKqdulvhRBwKecgkElbfwm0lGlKSvQOimT1gY... |
705,801 | Rearrange Geek and his Classmates | Geek and his classmates are playing a prank on their Computer Science teacher. They change places every time the teacher turns to look at the blackboard.
Examples:
Input:
N = 6
a[] = {0, 5, 1, 2, 4, 3}
Output:
0 3 5 1 4 2
Explanation:
After reshuffling, the modified
position of all the students would be
{
0, 3, 5,... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1618329863,
"func_sign": [
"void prank(long[] a, int n)"
],
"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 =... | {
"class_name": "Solution",
"created_at_timestamp": 1618329863,
"func_sign": [
"prank(self, a, n)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n n = int(input())\n a = list(map(int, input().strip().split()))\... | eJztms/qZkcRhl14IYdZSpBzqqurq70SwREXZhYijFlMQBDFi9D79XmrS9HRbzQm0c0EAoG8vz7n9NNdf976/vjDP//6Rz+of376Jf/xs9+9+dX7r77+8OYn15vn7fvnfvt+X3mtK655+TUuu57rfvPF9ebdb79698sP7778xW++/tB/cPP/DI2jDf4mr329ff+Ht+/f/P6L66OFJ//69YzrYcXneu7r2z2HBbSM1ZL+6rHG9yBEfj2pZyyWeYKVnsli/GFogaWFUgtq4ddvUUvVYrVerViL1rK1cq3dy796KfbC/LovG/owYxV7tAW3... |
702,931 | Check if a string is repetition of its substring of k-length | Given a string s, check if it is possible to convert it into a string that is the repetition of a substring of length k. Conversion has to be done by following the steps mentioned below only once:
Examples:
Input:
N = 4
K = 2
S = "bdac"
Output:
1
Explanation:
We can replace either
"bd" with "ac" or "ac" with "bd"
Inp... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int kSubstrConcat(int n, String s, int k)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nclass GfG\n{\n public static void main (String[] args)\n {\n \n Scanner ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"kSubstrConcat(self, n, s, k)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input())\n for tc in range(t):\n n = int(input())\n s = input()\n k = int(i... | eJytVEsOgjAUdGE8B+naGP+iV3DnysRnjED9JPhABUWNxkPofS0gikLVFgu8kNCZdqbzOOevvUIuGP0uexkcyBxt1yEdhVQAm4DjsabpOmCNFBVCPZvqDjVGlus8Z50AybGovEIrZYbVdINOWJ3y8WUevgro7faPW2IHDcAFWt4uKoANQYpqICJ5sS+CTCrg/j4A64LgVmTldMZfmWtkHdBertbPh78BLocaWOnDHXez9VgyBBnagDNqmtbWWpmGeBrY+o84Jo6WJzI88jC9383/6F+KAlkr+XTyZP+0J2tU4vpCgQAZJMYaR6JzAvTn... |
713,999 | Partition the Array | Given an arrayA[]ofNintegers. The task is to partition the array into four non-empty contiguous subarraysP, Q, R, and S such that each element of the array A[] should be present in any subarray.
LetW, X, Y, and Z be the sum of the elements inP, Q, R, and S respectively.
Find the smallest absolute difference between the... | geeksforgeeks | Hard | {
"class_name": "Solution",
"created_at_timestamp": 1676008416,
"func_sign": [
"long minDifference(int N, int A[])"
],
"initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*; \nclass GFG{\n public static void main(String args[]) throws IOException { \n BufferedReader... | {
"class_name": "Solution",
"created_at_timestamp": 1676008416,
"func_sign": [
"minDifference(self, N, A)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n A = list(map(int, input().strip().sp... | eJylVEFOwzAQ5IB4x8jnCnkdx0l4CRJBHCAHLqGHVqpAIPgD/BfX6wKNMkkAO9Jair07np3x6+nH29lJGpePcXH1ZO779XZjLmCk7au2FwtnUVh4i9IiWFTWrGC63bq73XR3Nw/bTT5Q2LZ/aXvzvMJxmnqfJg00aWioNVQagoZSg9dQkFLiSCmJGARaDQsWLH/6SWqU8UOe5HxJjoaE7jDtFARlikMQOBTwFAJjqDmCoJOxwEj+WR4BFWIr43UgMZeDFBAPYcDYnfyXSnKDKK7mMDjL3zJTlanIVGMqMT+RnLVv6AeZNoQvRyWE3MCE... |
704,401 | Euler Totient Sum and Divisors | Given a number N find the sum ofthe Euler Totient values of all the divisors of N.
Examples:
Input:
N = 5
Output:
5
Explanation:
1 and 5 are the factor
of 5 and Φ(1) = 1 and
Φ(5) = 4 and their sum
is 4 + 1 = 5
Input:
N = 1
Output:
1
Explanation:
1 is the only factor of
1 and Φ(1) = 1
Constraints:
1 <= N <= 10*... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int phiSum(int N)"
],
"initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])throws IOException\n {\n BufferedReader rea... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"phiSum(self, N)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n ob = Solution()\n print(ob.phiSum(N))\n... | eJyVlEEKwjAURF30ICXrIk1SU/UkghUX2oWb2kULgigeQg/jzqOZhn6o0JliVoXJy5/8P+kjen2iWVibt//YXtWpqttGrWOli0qnYRWVSmJVXury0JTH/bltZIvod7/llsS/9MqvpYWwyKOsTk1GynbiKOewWYd95sRkDijrINRJo4yBiEF9MDZb4Eoiw/5r2n4NyHzpMovNikwcS1u5cVRfGzp+g+cftEHf+CGkPgNJ9kI0iz4efycxuO7hiaFj64Mj2PXJGX6009FD8+9zJa974geALLhBCsmTFnz3nH8Bf9R4KQ== |
700,419 | Palindromic Array | Given an array arr[] of positive integers. Return true if all the array elements are palindrome otherwise, return false.
Examples:
Input:
arr[]
= [
111, 222, 333, 444, 555]
Output:
true
Explanation:
arr[0] = 111, which is a palindrome number.
arr[1] = 222, which is a palindrome number.
arr[2] = 333, which is a palindr... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1617623982,
"func_sign": [
"public static boolean palinArray(int[] arr)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n\n ... | {
"class_name": null,
"created_at_timestamp": 1617623982,
"func_sign": [
"PalinArray(arr)"
],
"initial_code": "# Driver Program\nif __name__ == '__main__':\n t = int(input())\n for i in range(t):\n arr = list(map(int, input().strip().split()))\n if PalinArray(arr):\n print(\... | eJzFlc+KFDEQxj148DGKPi9S+duJTyLYi4iOsCDtojMgiOLFm8f1ff2lOuDB3WUmu4NVU2HorqS+fF9S/ePp71/Pnpi9/MmfV1+nq/X6sJ9eyOSWtf2mC5l2X653b/e7d68/Hvb97f7TYbes35d1+nYh/8yqp8/yykxVceoITwQiEonIxEwUoopz5DnyHHmOPEeeI8+R58hz5Lm7QLx/8+HzvSjEewkSoyTJWWYpRaipAPMKsqBAiwq2pIDLCrpZgVcUfFUBWLHB6m1qpSQmczMwYJKaAQqT0AyUWOOhMaENntU2FIbHkBlGQ2u4bQe2... |
704,565 | Second Binary Digit | Given two numbers A and Bcount all the number between the given range whose second least significant digit in the binary representation of the number is 1.
Examples:
Input:
A = 1
B = 4
Output:
2
Explanation:
In the given range 2 (10)
and 3 (11) are the numbers
whose second least
significant digit in its
binary rep... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int find(int A,int B)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])throws IOException\n {\n Scanner in = new Scanner(System.in);\n int ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"find(self, A, B)"
],
"initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n A, B = input().split()\n ob = Solution()\n print(ob.find(in... | eJydkkEKwjAURF30IJ+sW0napBpPIhhxoV24SbtoiyCKh9D7GmOLiExK/KtC+iYzk39LHn0y87Ou3cfmzI626Vq2IiaMFSRYSqw6NdW+rQ67umuHQ27s1Vh2SembyKkARA6IAhICEJJktCsV6YqT4ABRABGOQcYKwOhx3HXjRLYxKpTTEijsB5zWQBW/0sP4CuWXDkNQlnNoGC9mBp8nCCGK/3aDNKTWyv8QasjvO0oM4wZrWsCa+D9b7E0GuiqDJt+wf1jc03KQ2N7nT+R/WJ8= |
705,146 | Next Permutation | Implement the next permutation, which rearranges the list of numbers into Lexicographically next greater permutation of the list of numbers. If such an arrangement is not possible, it must be rearranged to the lowest possible order i.e. sorted in ascending order. You are given a list of numbers arr[ ].
Examples:
Input:... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1730982469,
"func_sign": [
"void nextPermutation(int[] arr)"
],
"initial_code": "import java.io.BufferedReader;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n public static void main(String[] args) throws Exception {\n BufferedRe... | {
"class_name": "Solution",
"created_at_timestamp": 1730982469,
"func_sign": [
"nextPermutation(self, arr)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n arr = input().split()\n N = len(arr)\n for i in... | eJyVU8GKwkAM3YP7H2HOIp3pxNbFDxFUPKw9eKkeWhBkYT9i/V+TGafikoy1A20hr+8l76W/k+vy8yNcK6SX9cUc2lPfmS8wdtNaKMGBhzmgmYJpzqfmu2v2u2PfJdADAZvW/EzhmQGpVlGNURYKhQWhoKojVERLTAuoqcY6PrKpHUUeJGxF3yxENkt6CHzXedKR+4kK+bn8MBdj5T7KUHcvZooI5uKn7DQGFTqqywNC6QXJL393ucx0wzgbXJ6reaWc8kmlrCSGOHF0WPeYUcU9KcaqW1hClesGg7sJJ7JU7p2ZFJZhgV2uF5/SFkg0... |
701,429 | Longest Common Subsequence | Given two strings str1 & str 2 of length n & m respectively, return the length of their longest common subsequence. If there is no common subsequence then, return 0.
Examples:
Input:
n = 6, str1 = ABCDGH and m = 6, str2 = AEDFHR
Output:
3
Explanation:
LCS for input strings “ABCDGH” and “AEDFHR” is “ADH” of length 3.... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1618298485,
"func_sign": [
"static int lcs(int n, int m, String str1, String str2)"
],
"initial_code": "import java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) {\n\n Scanner sc = new S... | {
"class_name": "Solution",
"created_at_timestamp": 1618298485,
"func_sign": [
"lcs(self, n, m, str1, str2)"
],
"initial_code": "# Initial Template for Python 3\nimport atexit\nimport io\nimport sys\n\n# Contributed by : Nagendra Jha\n\nif __name__ == '__main__':\n test_cases = int(input())\n\n for ... | eJy9VEtOwzAQZQH3sLyukB2IitjZTv//fxKMWEAWbEwXqYSEQBwCjsmOAzBOm4SosUUKIlFGVmbe+M3zjF+P3z9PjpLH/4DF1RO+V+tNjC8RplJRBIZJxaXCNYSjx3V0G0d3Nw+beBdEpHoB53MNFZEOcgDJtp8B6xiw6a5mJC1DQjoXuQDjwmtI1Wy1O11N5EwqP5Aq1MZahYkPQeDXb0UNqMaxA4BEC3CI6i6iJBOAMcY5F0J4xjznZXlAL0ryRDsde/3BcDSeTGfzoswNT3Co8QLV83ipWs3kv5U+/WZLSiHILVDICSyWKz8IzR4b... |
706,254 | Open the gates | Geek and his friends went on a trip to one of the hill stations in Geekland. While trekking they found a treasure map, it was in the form of r x c size board, each cell on the map denotes a latin uppercase letter. On the bottom of the map it was written that there are n gates with a specific name and if they could find... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public String[] wordBoggle(char board[][], String[] dictionary)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])\n {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"wordBoggle(self,board,dictionary)"
],
"initial_code": "# Initial Template for Python 3\nif __name__ == \"__main__\":\n t = int(input())\n for _ in range(t):\n N = int(input())\n dictionary = [x for x in inp... | eJztWUuP40QQ5sAPKc0NaUGTEbuw3Dp2j90bu+2xOzPJYMQB9sDF7GFXQkIgDty4wv/lq+p24mRsZ3aWxz48ozjtrqru+urVj/z28V9/fPKR/G1+R+Prn89+aF+8enn2FZ0tmvZJ06plFOvdp2kXj2nxGN20pIhi0kPfTTtBpLhpJ4ikm3aCSFBhgjjP/dC5m/bsEZ09/+nF8+9ePv/+2x9fvQxhcBgA1LS/gvWXR3QYKV80baqzrKCbospiKrcuLSwlWq8oUzamqIg15aps2otzujgHNybP8F/QZKtpTzB0raY9OZZvvQZjcVo/bjGY... |
703,884 | Find n-th term of series 1, 3, 6, 10, 15, 21 | Given a number N, find the N**th term in the series 1, 3, 6, 10, 15, 21…
Examples:
Input:
N =
4
Output:
10
Explanation:
The 4
**th
term of the Series is 10.
Input:
N =
3
Output:
6
Explanation:
The 3
**rd
term of the Series is 6.
Constraints:
1 <= N <= 10**4 | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int findNthTerm(int N)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader r... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"findNthTerm(self, N)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n\n ob = Solution()\n print(ob.findN... | eJzlVD1PwzAQZWBlYmOKMlfIZ/scl1+CRBADZGAJHVoJCYH4EfB/OV/s0JIvh6QRElF7ypPj8917z/d++nlxdsLP9Tm93Lykj+Vmt02vkhTyEtJVkhbPm+J+WzzcPe2230tveZm+rpIf3wt6OvYgLbl/21ZJW/t3Vyf25VDVcl6u6RlIJlHQr0qj6fM6Z98BmoukUlVMqYqjGcwKwmcLhVOwHDOOhiNy1BwVR8kROEZRftAnAUsAAsgIqAAMARMAooB6jyaAASgisU7gGLUBAAplejXKmP1ojaQFaWnPIJu4pxGxhdES+R59d01nO206... |
705,230 | Count Sorted Rows | Given two integers N and M and a matrix of dimensions N*M.Count all the rows in a matrix that are sorted either in strictly increasing order or in strictly decreasing order.
Examples:
Input:
N=3,M=3
Mat=[[1,2,3],[6,5,4],[7,9,8]]
Output:
2
Explanation:
The first row is sorted in strictly
increasing order while the s... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int sortedCount(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 Bu... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"sortedCount(self,N,M,Mat)"
],
"initial_code": "# Initial Template for Python 3\n\nimport math\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N, M = map(int, input().strip().split(\" \"))\n... | eJztV8tuUzEUZMEvsD/KukLXb5sPQUikYgFdsAksWgkJgfgI+F9mJs6ridUATYqgrdza947Pc86x77enPy6fPdHPq5eYvP48e7/4eHM9e2EzN18kS/OFM2/BIqcJ/wKWeOUma1atWCYiWMK0zRf9maXZhc2uPn28ent99e7Nh5vrLhRCvs4Xsy8XtqspU07G1gqxkO2oAoqcrRRtGSKdyVw0F2yFonUbAfOFhxDMqrliLpsbWZQHFkWLFElbkvkuUGv44GFGtjpfVPyL5gey40B2sdBD1b2iOrnVoys31hC67X7RfK8gwFqYHSaLMHuy... |
712,033 | Pattern 16 | 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:
5
Output:
A
BB
CCC
DDDD
EEEEE
Constraints:
1<= N <= 20 | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1662630518,
"func_sign": [
"void printTriangle(int n)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass Main {\n // Driver code\n public static void main(String[] args) throws Exception {\n BufferedReader br =\n new Buff... | {
"class_name": "Solution",
"created_at_timestamp": 1663316374,
"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... | eJzt3Nly22aXheE+6JO+C5eOXV0AZ+YsVuZ5jhNvxyEBMHGGbSWREieOXX0HfdIX3BQXbYsWKQLgAHzAu+rXk0lOkdhrb0muv/I//3n3f8/+6z/uPTl56GcX5yev3Trpmsfz/0Xmnejk9q2T7PFZlpxn6YNHF+fLT3nd/Jn53Dt3zE9PT83fmMf8zcuYv7WI+duK+TvLmL/7PObvvci+/23vv4z5B1di/uHVmH+0EvOPV2P+ySsx//TVmH92LeafX4/5F2uyePMnT2/fujKCzvz59837mx9/DR/VTTO8/hZ75sP5u7ws23jetJ3faVUN... |
703,514 | Print N-bit binary numbers having more 1s than 0s | Given a positive integer n. Your task is to generate a string list of all n-bit binary numbers where, for any prefix of the number, there are more or an equal number of 1's than 0's. The numbers should be sorted in decreasing order of magnitude.
Examples:
Input:
n = 2
Output:
{"11", "10"}
Explanation:
Valid numbers ar... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"ArrayList<String> NBitBinary(int N)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedRe... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"NBitBinary(self, n)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n = int(input())\n ob = Solution()\n answer = ob.NBitB... | eJxc2c3KdEt2XWGDfQvuH752NZ4Eu6MrMbhADek01DmqxikQCBvfiO/VWO+OnTGHrR+WVswcOXPFjPV+1P/5L//j//7X//yf/ue///qXP/729z9//cNvvz5//ePz33/95bdfv//b337/pz9//+d//Ne//3l6+/9+29LW0rd90Yte9FYvfOELX/jCF77wLf//4z+p05d+9KIXvejDj3/xL/7Fv/gX/+Lf+v8P+5/U6Us/etGLXvThr3+Zv8xf5i/zl/nL/GX+Mn+Zv8xf5i/zl/nL/GX+Mn+Zv8xf5i/zl/nL/O38f8b/SZ2+9KMXvehF... |
705,309 | Check if given four points form a square | Given coordinates of four points in a plane. Find if the four points form a square or not.
Examples:
Input:
points=(0,0),(0,1),(1,0),(1,1)
Output:
1
Explanation:
These points form a square.
Input:
points=(0,0),(1,1),(1,0),(0,2)
Output:
0
Explanation:
These four points do not form a square.
Constraints:
0<=X-cor... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int fourPointSquare(int points[][])"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedR... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"fourPointSquare(self, points)"
],
"initial_code": "import math\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n points = []\n for i in range(4):\n points.append(list(map(in... | eJytVM1OBCEM9mB8jobzxgDOHz6JiRgPOgcvuIfZZBOj8SH0Eb35ENJ2WTCRcarDgfbLF76WUvp6+v55dkLr6iM610/qIWx3k7oEZXzQoH0wOq7s0I4UOWoDatxvx7tpvL993E357IsP6nkDPwhqcHH5gDtisrgJxQxn44MtHas5VXSkgvaiaaHrB6czcAyakmkSIwzQUgVbriAaUwJmTMkYYYCeZAbWzODAmJJhIA2g04O57Dh+Tn5W6SNavCbQzsCUgBlTMtKMDfYGtkYylvojGqFQbIeuB2yBb8AyGEqGgV09gI5Ud4T1CPo/V2iW... |
706,062 | Coins of Geekland | In Geekland there is a gridof coins of size N x N. You have to find the maximum sum of coins in anysub-gridof size K x K.Note: Coins of the negative denomination arealso possible at Geekland.Example 1:
Examples:
Input:
N = 5, K = 3
mat[[]] = {1, 1, 1, 1, 1}
{2, 2, 2, 2, 2}
{3, 8, 6, 7, 3}
{4, 4, 4, 4, 4}
{5, 5, 5,... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1619174400,
"func_sign": [
"public int Maximum_Sum(int mat[][],int N,int K)"
],
"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 stat... | {
"class_name": "Solution",
"created_at_timestamp": 1619174400,
"func_sign": [
"Maximum_Sum(self, mat, N, K)"
],
"initial_code": "if __name__ == \"__main__\":\n t = int(input())\n for _ in range(t):\n n = int(input())\n matrix = []\n for _ in range(n):\n matrix.append... | eJztWctuJEUQ5MCHpCyOW6vKehdfgsQgDuADl2EPXgkJLeIj4Ee5cSMiq5Bsa2pcDAatVr3uXtmezKzsyFdk+9fPf//zi8/s31d/4Juvf7774fzu/cPdl3Knp7P60zlKEJUsRao06eIFHwSJkvCrho8iPuxST+eCbxKkKRXxgZcGEzJkHxk4nTu+qTLkh/1+OsPwM9nA09PTsyXydBp/bASSz+WClNP58Y/DFPyEhbs3cnf/07v77x7uv//2x/cP85EL3PgFn354I8+AyKezU9m+IB1k+4J0lO0L0km2L0hn2b4gXWT7gnSV7QvSTbYv... |
705,139 | Minimum Value Assigned | Given an array, arr[], Geek wants to assign a value to each array element. The minimum value that can be assigned to an element is 1. For every pair of adjacent elements, the one with the higher integral value should be assigned a higher value. Help Geek assign the smallest possible value to each element and return the... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int minValue(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 BufferedReader... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"minValue(self, arr)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n arr = input().split()\n N = len(arr)\n for i in range(... | eJzFVMFqwzAM7WHQ3xA+l2FZcRPvSwbL2KHNYZeshxQKpWMfsX3PbvuuKWroWooc1+uYQx7GRNKz3lPebj6+phNZ95+8edia53a17swdGKxbtBCgghLm4KEAAgdoZmCazapZdM3y6WXdDV97X7evdWt2MzjNQYAcipwgcHifiMArSZxVkqDULiL1MR5KwsFpwU4Ltrxgj4EXnB0cnfZbrQCp7JiV8CPhyRfUr6i12EPSc2nT3dC5kVdJS6og9tCtffsqwVJwLugFC0ESdIIXmw8H6T0br2Qn91IlW5qJJtpC8UWoTs0RchyiyYZJjsrx... |
703,082 | Sum of two large numbers | Given two strings denoting non-negative numbers X and Y. Calculate the sum of X and Y.
Examples:
Input:
X = "25", Y = "23"
Output:
48
Explanation:
The sum of 25 and 23 is 48.
Input:
X = "2500", Y = "23"
Output:
2523
Explanation:
The sum of 2500 and 23 is 2523.
Constraints:
1 <= |X|, |Y| <= 10**5 | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1616469659,
"func_sign": [
"String findSum(String X, String Y)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedRe... | {
"class_name": "Solution",
"created_at_timestamp": 1616469659,
"func_sign": [
"findSum(self, X, Y)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n x = input()\n y = input()\n ob = Solution()\n a... | eJxrYJlqxMYABhHaQEZ0tVJmXkFpiZKVgpJhTJ4BGCnpKCilVhSkJpekpsTnl5ZA5UEytToKqDqAyBIEcOoyNAABbFqh+gzJ0AqTsYSpwGcAPssJuB0ka4FNuynEXFMirMem3QDhBbL9TpZefMFthNelZIUySiyjcKgR+YYxMegWIAUOciAT8oClqYkhaVbhcwN+R0B0QBAtnWxgQFFYEbAdbDqOBBaDbHge0HQcxpiaYE1yIK15uB2Nx1WGpuaEAmVQRCrevGSJPWSRCqyYGDxFFtAEYxOsZRZKICA8RyhvQ90TO0UPAEwH0Pg= |
703,601 | Largest number in one swap | Given a non-negative number N in the form of a string.Find the largest number that can be formed by swapping two characters at most once.
Examples:
Input:
N=768
Output:
867
Explanation:
Swapping the 1st and 3rd
characters(7 and 8 respectively),
gives the largest possible number.
Input:
N=333
Output:
333
Explanati... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"String LargestSwap(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 re... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"LargestSwap(self,S)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n S = input()\n\n ob = Solution()\n print(ob.LargestSwap... | eJydU0sOgjAUdMFBSNfE9JUCxZOYiHGhLNxUFpCQGI2H0EO68wi2iJ+QTlXeqgkzw3Tm9RRcbsGkm/nVHBZ7ttVVU7NZyKjQJGKZpJnKeaFZFLKyrcp1XW5Wu6buUXkPIQM5GtQhCgca/DlQ4xPi1hCYLOCfuWOgjBvs1BUkM6niVGZQTVmIeEDc3rARwMhxBTB5T+Lwbp6gkTOFrSnEQQyNbvOupbf5Q6n0tUvvRuBcCw79248oqe49wc30P7TEcAkJC/q3NGjF+hhvZChr1EZrmSQBzUTs4tjcfVuvX2u/PE/vchR9VQ== |
703,932 | Reverse digits | You are given an integer N,reverse the digits of given number N, ensuring that the reversed number has no leading zeroes. Return the resulting reversed number.
Examples:
Input:
200
Output:
2
Explanation:
By reversing the digits of
number, number will change into 2.
Input:
122
Output:
221
Explanation:
By reversin... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1619260432,
"func_sign": [
"public long reverse_digit(long n)"
],
"initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG\n{\n public static void main(String[] args) throws IOException\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1619260432,
"func_sign": [
"reverse_digit(self, n)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n = int(input())\n ob = Solution()\n ans = ob.rever... | eJyllEEOgjAQRV0Yz0G6JoYWCsWTmIhxoSzcIAtITIzGQ+jF3HkbG5ICpTO04CwIpMP7nc78Ppfv72rRxPYjX3Y3ci7KuiIbj9CsoIEeWUF8j+TXMj9W+elwqasu9yEX776nA1KRxDwKGQ0oCyMeowAtKxEpwmvXFRffkZkJE4NhTC/SCBQBpYJMPtwVR5lQKlzqMPBKzUy0HfJo+8/Rhhi5IFUYLREoFcwdH8UJs2Mdx79nRxJgTvuKHbNFr/kRadqsjuEOUpimCqaXoStl40qzBQKpMBMuLQhbw9XSFDexcQdNtYzzJaZwmICLmM2W... |
703,725 | Minimum Operations | Given a number N.Find the minimum number of operations required to reach Nstarting from 0. You have 2 operations available:
Examples:
Input:
N = 8
Output:
4
Explanation:
0 + 1 = 1 --> 1 + 1 = 2 --> 2 * 2 = 4 --> 4 * 2 = 8.
Input:
N = 7
Output:
5
Explanation:
0 + 1 = 1 --> 1 + 1 = 2 --> 1 + 2 = 3 --> 3 * 2 = 6 -->... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1618400325,
"func_sign": [
"public int minOperation(int n)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nclass GfG\n{\n public static void main(String args[])\n {\n Scanner sc = new Scanner(System... | {
"class_name": "Solution",
"created_at_timestamp": 1618400325,
"func_sign": [
"minOperation(self, n)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n n = int(input())\n ob = Solution()\n print(ob.minOpe... | eJydkkEKwjAQRSP2ICHrIk6atsaTCCouNAs3tYsUCiJ4CL2sK2k2sTA/EGfb95nJ638W70Uhwuw+SyH2d3Xt+sGrrVR06EiVUrmxd2fvLqfb4OMn9SjlHNYA1hxcAbjiYJMD01ojnti7bRi0go3UgDb8QYCueToMctnwGbOp2wZl2CdMmhL/gdhFk6ifLLSm2adp1JCWbUiifxYGshJRNzyNdzePojagrKbMfVE7/ePdphse7B9fqy/1/jj+ |
705,204 | Nitika and her queries | Nitika recently read about XOR operation and she got obssessed with it. She has an array a containing N Positive integers.She wants to perform Q queries on the array.In aquery She gives two integers L and R.(1 based indexing).Now, she asks what is the xor of all the elements of the array after not including the subarra... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static List<Integer> specialXor(int N, int Q, int a[], int query[][])"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nimport java.lang.*;\n\nclass GFG{\n public static void main(S... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"specialXor(self, N, Q, a, query)"
],
"initial_code": "# Initial Template for Python 3\n\nimport sys\nsys.setrecursionlimit(10**5)\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N, Q = map(... | eJzNlU2OEzEQhVmw4hRPLXaMkKv8z0mQaMQCsmDTzCIjISEQh4D78qq6EdIoDpNMIuik7U5sV331qtz+/vTni2dP/Hr9nA9vvkwfl9u7/fQKk8yLBOR5SahoyOgoEARogAQOQm2ME6r/VvR5iSjzMt1g2n2+3b3f7z68+3S33wwqx6Xx5jdxPh+/cfLXG9zzmsFhUfBBQIv0XqEkEIEkSCQK0WwSolMKKTKqQUgcA5jteSGGDlwztGKWIl0aQKJzhcVHl8n9Z/PPvrkOVIQs1dUIJkd3OdSUaB6KRaym0gCKq6J57usd1+4wXfZwkVwS... |
705,752 | Maximum sum Rectangle | Given a 2D matrix M of dimensions RxC. Find the maximum sum submatrix in it.
Examples:
Input:
R=4
C=5
M=[[1,2,-1,-4,-20],
[-8,-3,4,2,1],
[3,8,10,1,3],
[-4,-1,1,7,-6]]
Output:
29
Explanation:
The matrix is as follows and the
blue rectangle denotes the maximum sum
rectangle.
Input:
R=2
C=2
M=[[-1,-2],[-3,-4]]
Output:... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1731044371,
"func_sign": [
"int maximumSumRectangle(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 Buffered... | {
"class_name": "Solution",
"created_at_timestamp": 1731044371,
"func_sign": [
"maximumSumRectangle(self,mat)"
],
"initial_code": "# Initial Template for Python 3\n\nimport math\nimport sys\n\nif __name__ == '__main__':\n t = int(sys.stdin.readline().strip())\n for _ in range(t):\n N, M = map... | eJzFVMFKxDAQ9SB+xxDw1kiaNO2uXyJY8aA9eIl76IIggh+h/+vMpHaXNhM3IhiakrQzb17em/b9/LO6OONxc4mL21f1FHb7UV2DqvtQA92MMaoCNbzshodxeLx/3o/fIfiqD+qtgkSeziRqKdOBixWBQyDGHdYwZS5CCvlxlZg9I074ZvGiENmDJwA4unhfM92jB8uAzF6mkGLQQEMGWHC08NBCB5s+bJEC1EjEErxD2Aanx9kK+N1GhCdaFjSi0AZBWtAdaEzQW5INJxHHUlgJC2EdsYxPlol9QOef9GNd4gNJj7QfltUgxChHH2Y9... |
713,976 | Optimal Array | You are given a sorted array a of length n. For each i(0<=i<=n-1), you have to make all the elements of the array from index 0 till i equal, using minimum number of operations. In one operationyou either increase or decrease the array element by 1.
Examples:
Input:
N=4
A={1,6,9,12}
Output:
0 5 8 14
Explanation:
For i... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1675772812,
"func_sign": [
"public long[] optimalArray(int n,int a[])"
],
"initial_code": "import java.util.*;\nimport java.io.*;\n\nclass GFG {\n public static void main(String args[])throws IOException\n {\n BufferedReader in=new BufferedR... | {
"class_name": "Solution",
"created_at_timestamp": 1675772812,
"func_sign": [
"optimalArray(self, n : int, a : 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()] #... | eJzNVctKxDAUdSH4G5euJ5J3M36JYMWFzkIXdYQZEETxI/R/vclpp7GaUBHEhnKnuSfnJPeReT1+fzg5Ss/5Hf+4eGpu++1+15xRo7teSX5JkyFLjjy1FGhNaTa9/BF40rPTMkiTalbUbB63m+vd5ubqfr8buCRFGstIXs4wT1qSdtT1L10fnSJ6RXQL+EUGaJ5XlG1MsbSLG6uM4j5qoyCm+axCyfiQWMMEmBbGwzgYC2NgNExazxqwmAQCcKwFEVghkfTKUc3YbMaAXSo4lJ9QMaiTNhv47ECBdQ6THowtfEFNzIOwLIbMx+rIgDWz... |
703,041 | Toppers Of Class | There is a class of some students and the task is to find the top k marks scorers. You need to print the index of the class's toppers, which will be the same as the student's index in the input array (use 0-based indexing). First, return the index of the students having the highest marks then the students with second h... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public List<Integer> kToppers(int[] arr, int k)"
],
"initial_code": "import java.util.*;\n\n//Position this line where user code will be pasted.\npublic class Main {\n public static void main(String[] args) {\n Scann... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"kToppers(self, arr, k)"
],
"initial_code": "def main():\n t = int(input())\n for _ in range(t):\n arr = list(map(int, input().split()))\n k = int(input())\n\n ob = Solution()\n result = ob.kTo... | eJy1VUtOxDAMZcGCO7Cxsh6h5j/DSZAIYgFdsAmz6EhICMQh4L64SVo6ad2mMLSRbDWt/fKe7X6cf7GLs3DdXKJz+8qe/P7QsGtg3HlepQt26eqcbedYfIttgNUv+/qhqR/vnw9NClA5/+48e9sAFXXWc15QgYGDAEmFh9Hd5pyPBQo0GLCAByPi4tlx14bb4Nsav5H4LW7J5eAkFyDCQkd2S4WlkQFNBN4FpBFzm6Ki2ch5hWMlt5m1mTWZ1TSoEZUUkYP8KW3KlpLoaFQ0MhoRDY+mWiCdSK07EkiHjxxR4jivCDh9WQVm5sBNdFvZ... |
703,069 | Number of positive integral solutions | You are given an equation of the form x1+x2+...+xN=K. You need to find the total number of positive integral solutions of this equation.
Examples:
Input:
s = a+b=5
Output:
4
Explanation:
(4,1) , (1,4) , (2,3) , (3,2)
Input:
s = a+b=1
Output:
0
Explanation:
No solution exist.
| geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"long posIntSol(String s)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GfG\n{\n public static void main(String args[])\n {\n Scanner sc = new Scanner(System.in)... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"posIntSol(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 solObj = Solution()\n print(solObj.posIntS... | eJxrYJnKxsoABhH/WRgYoquVMvMKSkuUrBSUDGPyErWTbI1i8pR0FJRSKwpSk0tSU+LzS0sQCuqAkrU6Cmi6bE1J1wO0ydAApzZL3Nq0k20NceozwKsPtzPN8OnTTrE1IceDIJ3aqbbG5LkWrBdPEBkaEXC0dqp2mq0hbj8bGRgYETZBO93WnBzPJ+JJSAT8DQpt8pMVLOQodQU0+MgOPLgvSPdCMt60akLY3Yl4Yw2Px6E2w0xDT8fEmE6880CCVIgscCZBtoCgYbDSJXaKHgAWcpfM |
713,974 | Number of Good Components | Given an undirected graph with v vertices(numbered from 1 to v) and e edges. Find the number of good components in the graph.A component of the graph is good if and only if the component is fully connected.Note:A fully connected component is a subgraph of a given graph such that there's an edge between every pair of ve... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1715520969,
"func_sign": [
"public static int findNumberOfGoodComponent(int e, int v, int[][] edges)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass IntMatrix {\n public static int[][] input(BufferedReader br, int n, int m) throws... | {
"class_name": "Solution",
"created_at_timestamp": 1715520969,
"func_sign": [
"findNumberOfGoodComponent(self, e : int, v : int, edges : List[List[int]]) -> int"
],
"initial_code": "class IntMatrix:\n\n def __init__(self) -> None:\n pass\n\n def Input(self, n, m):\n matrix = []\n ... | eJzFVMFOwzAM3YHDPiPKeUJzG6fdvgSJIg7QA5ewQydNQkz7iPEd3Pg+8tKiMqi3pVq0qrXS1nl+tl+8u/n4mk7CdffpF/dv+sWt1o1eKk2VM5WzlSOVweQw/kuGVYZVroyeKV1vVvVTUz8/vq6bbq/fsK2cfp+pQ0DuAQNMDhijGN84oAqAJADS3D/8jyO1kCFWAVPCLGCw409shqOFY6FKgQALBACcDad0ANuR6OrGcLFwKYR4Rojn0RanwlH7g4/hH+lQqOlgAOqwf2dBeOXIqtm2cIPCCjqwfZUiE0B1zFkNKVtB5ENdgV+sFGRx... |
714,078 | Count Cyclic Paths | Given atriangular pyramidwith its vertices marked asO, A, B and Cand a numberN, the task is to find the number of ways such that a person starting from the originOinitially, reaches back to the origin in N steps. In a single step, a person can go to any of its adjacent vertices.
Examples:
Input:
N = 1
Output:
0
Expla... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1676786428,
"func_sign": [
"public static int countPaths(int N)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass GFG\n{\n public static void mai... | {
"class_name": "Solution",
"created_at_timestamp": 1676786428,
"func_sign": [
"countPaths(self, N)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n ob = Solution()\n print(ob.countPat... | eJydk8FKBDEMhj3sgww9L9I0TZr4JIIVDzoHL+MeZmFBlH2I3ZsPa2dYBA9/xc2p0Hz9w5+/x835a3Oz1v25HR7ew+u028/hbghUJwrbIYyH3fg8jy9Pb/v5chXr9Fmn8LEdfvcn0M+gn0G/gn6KERAlkVDMnDC5FKCTamI2QbrShcnNY3EHsK+F5hbJRMm6sCFlIYtcNPfgAmBj5yxWoGGAo1wU7XNxmTpONaNyFOvP28lFyaSlCSC3pLMmV5dUxAXN/semUOYX7ici1+FX69b6f24ZlnrBaD9JI7OjBwR73NKsFJ2gtq/qtBqFUm1G... |
702,661 | Maximum value | Given an array arr[] of integres. Find the maximum value of arr[j] – arr[i] + arr[l] – arr[k], such that i < j < k < l.Examples:
Examples:
Input:
arr[] = [1, 2, 3]
Output:
-1
Explanation:
arr.size() < 4 so no such i,j,k,l is possible.
Input:
arr[] = [4, 8, 9, 2, 20]
Output:
23
Explanation:
Here i = 0, j = 2, k = ... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1725623061,
"func_sign": [
"public int findMaxValue(int[] arr)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws IOException {\n BufferedReader reader = new Buffer... | {
"class_name": "Solution",
"created_at_timestamp": 1725623052,
"func_sign": [
"findMaxValue(self, arr)"
],
"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 solution = Solution()\n while t > 0:\n t... | eJydk90KgkAUhLuo9xj22sIt15+eJMiIKKFuzAuFIIIeot43dz1FRpbn7LK4IDN8M0evw/t+NHBrsakvy7M65EVVqjmUTnPt22MXNHpclAeVnYpsW2a79bEqyWlcW6mLh7Z5WHtjBjosaZDmphH6LF1s48AgRoQEIQJMWXrj9InTh1xiDbfZMur2y4PLbkBbgN4etTSE7Et5q53XemvkNHC52etn4MFrqoCKIKZnLN4snIRJLao6YtfTlfNjfrLY5O3/MXcveoJYkgZFxtJl/9NsdZs8ALfCja4= |
710,138 | Graph is Tree or Not | You are given an undirected graph of N nodes (numbered from 0 to N-1) and M edges. Return 1 if the graph is a tree, else return 0.
Examples:
Input:
N = 4, M = 3
G = [[0, 1], [1, 2], [1, 3]]
Output:
1
Explanation:
Every node is reachable and the graph has no loops, so it is a tree
Input:
N = 4, M = 3
G = [[0, 1], [1, ... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1705730392,
"func_sign": [
"public boolean isTree(int n, int m, ArrayList<ArrayList<Integer>> edges)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\npublic class GFG {\n public static void main(String[] args) {\n Scanner scanner ... | {
"class_name": "Solution",
"created_at_timestamp": 1647470337,
"func_sign": [
"isTree(self, n, m, edges)"
],
"initial_code": "# Initial Template for Python 3\n\nfor _ in range(int(input())):\n n, m = [int(i) for i in input().split()]\n edges = []\n for i in range(m):\n a, b = map(int, inp... | eJy11c2KU0EQBWAXgq9xyHqQW9X165MIRlxoFm7iLDKMIA4+hL6vp6OiI0nwBswiBG7XV3W7D50vT789PHty/Ly8549Xnzbv97d3h80LbGS7Fyzb/eYGm93H293bw+7dmw93h9+PH/jw8w0e1yj4tcyvlYUD42ehQKdzvvdyltA/iZUDGOzxAGOK66fwk46tnsfhp53lAnZuqDiH2XywcjJZ0Bc0R8yGud0naruvuXh1B7ZY26Mhy3E4mUUCYZkwjyyUAWGpGITF4hCWS0AISEJISEGISEOp6AKdaWbv2VyhVJQBo6IGpaIOpaIBpaIJ... |
705,358 | Possible paths | Given a directed graph and two vertices ‘u’ and ‘v’ in it. Find the number of possible walks from ‘u’ to ‘v’ with exactly k edges on the walk modulo 10**9+7.
Examples:
Input:
graph = {{0,1,1,1},{0,0,0,1},
{0,0,0,1}, {0,0,0,0}}, u = 0, v = 3, k = 2
Output:
2
Explanation:
Let source ‘u’ be vertex 0,
destination ‘v’... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int MinimumWalk(int[][] graph, int u, int v, int k)"
],
"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[] arg... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"MinimumWalk(self, graph, u, v, k)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n = int(input())\n graph = []\n for j in... | eJztWs1O4zAQ5rAPYuWMVnaaxAlPgkQRh90e9pLlUCQktNI+BLwMN96MtGmdmfE3SQoCoWBKlNj+4m/m84x/1P7/8fSSne3/Lp+7h6uH7E97e7fNLkzm1m25bq1x3ccau273t11xeLQ9YF/oaw9Yawqzys5Ntrm/3fzabn7f/L3bHjrO123279xwqor0dCTri4EjdB2KfeFQPFoVWkpTKBaskAU1cZZ7FKoGS4hprIpZRE0MVUNFZDex3ZtKsd1bZLwjI2GpwY4W+ZjRaq4rFxv6zNE28qr3jBDIMRMa8MqAbIxXdChhGLmc6sB8jLWI... |
702,948 | Maximum product of two numbers | Given an array arr of non-negative integers, return the maximum product of two numbers possible.
Examples:
Input:
arr[] = [1, 4, 3, 6, 7, 0]
Output:
42
Explanation:
6 and 7 have the maximum product.
Input:
arr[] = [1, 100, 42, 4, 23]
Output:
4200
Explanation:
42 and 100
have the maximum product
.
Constraints:
2... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public static int maxProduct(int[] arr)"
],
"initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass GFG {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"maxProduct(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 ... | eJytVE1LxEAM9SD4N0LPiySZz/pLhF0R1B681D3sgiCKP0L/r2PZZLQ0tGIfPYQhTSbvvcn7+efdxdmA620Jti/NY78/HporaGjXtwKQIAOhAAi42UDTPe+7+0P3cPt0PJz+1R81ede/7frmdQO/OwQtJhFpxFBaGA34lESabDQgdj7ElMsIOcXgHRPIWdYztOZIwUfCEDOyo5jYmsMJwAsgCCAKjDYu4fcX28jD56w2dZo6A6o4rVFec4UBsspXbav0VaKiN5QBoQwECQp7/1V/UhwBsACUXYs/bpkyYYwJU6bcOqPhlKElShpFMP0g... |
703,129 | Number of occurrence | Given a sorted array Arrof size N and a number X, you need to find the number of occurrences of X in Arr.
Examples:
Input:
N = 7, X = 2
Arr[] = {1, 1, 2, 2, 2, 2, 3}
Output:
4
Explanation:
x = 2 occurs 4 times in the given array so the output is 4.
Input:
N = 7, X = 4
Arr[] = {1, 1, 2, 2, 2, 2, 3}
Output:
0
Explana... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1729749951,
"func_sign": [
"int countFreq(int[] arr, int target)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n Buffered... | {
"class_name": "Solution",
"created_at_timestamp": 1729749951,
"func_sign": [
"countFreq(self, arr, target)"
],
"initial_code": "# Initial Template for Python 3\nimport bisect\n\n# Main\nif __name__ == '__main__':\n t = int(input())\n\n while t:\n t -= 1\n A = [int(x) for x in input()... | eJztmb0KwjAQxx18kJi5SNJ2qU8iGHHQDi6xQwuCKO5uou9rTT8sytGmH5iUS4K/QhFy18vd/dvr9HmfTdRY3tKL1YnuZZTEdEEoF5ITt5yevVNIjzqEhsco3MbhbnNI4tzGwBfyIiQ9O+TLckZwNVtCBoB3GeTcSlhZPFNDAMM5aPgoppCu5hMP1CAIhG0oghc66gzMci3yg/7J+nsy6CulgL6CHczUKC90nZ39iyCRyB/W5D2s9IiRoQjed2MPVaP+ynCXmui7DZTV32V3J8EOGw9qdtaxIRgsspRGNiHGR9UvGuFRK5OVCftH2INc... |
707,621 | Count the number of subarrays | Given an array A[] of Nintegers and a range(L,R).The task is to find the number of subarrays having sum in the range L to R (inclusive).
Examples:
Input:
N = 3, L = 3, R = 8
A[] = {1, 4, 6}
Output:
3
Explanation:
The subarrays are [1,4], [4] and [6]
Input:
N = 4, L = 4, R = 13
A[] = {2, 3, 5, 8}
Output:
6
Explana... | geeksforgeeks | Hard | {
"class_name": "Solution",
"created_at_timestamp": 1621854679,
"func_sign": [
"long countSubarray(int N,int A[],long L,long R)"
],
"initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*; \nclass GFG{\n public static void main(String args[]) throws IOException { \n B... | {
"class_name": "Solution",
"created_at_timestamp": 1621855035,
"func_sign": [
"countSubarray(self, N, A, L, R)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N, L, R = map(int, input().strip().split())\n A =... | eJzdls+KE0EQxj149CGKOS/S9adnpgXfQ3DEg+bgZdxDFhZE8SH0fe2vasaDbIUEsghJMp0mmXy/6qqvq/Pz5e+3r174493YJ++/DV/W+4fj8IYGXlYuxJW0+KySYKgUn/p7He5oODzeHz4dD58/fn047r+dlvXHsg7f7+gfxfgZFElIybrOSBPN1FyXiYVYia0zEvE6Z+JdoJQeZpcXvGevRFg4Exasvi5rpSefWaAl0Zt7BhDqso4ekZb4gKzQXGjKAmTJV16LS/rSoQixyAe+GTHvDOmX9stqyqinShcybghP9F/QDpkKllCobeH0... |
701,758 | Most frequent word in an array of strings | Given an array arr containing N words consisting of lowercase characters. Your task is to find the most frequent word in the array. If multiple words have same frequency, then print the word whose first occurence occurs last in the array as compared to the other strings with same frequency.
Examples:
Input:
N = 3
arr[]... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public String mostFrequentWord(String arr[],int n)"
],
"initial_code": "//Initial Template for Java\n\n/*package whatever //do not write package name here */\n\nimport java.io.*;\nimport java.util.*;\nclass GFG {\n\tpublic sta... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"mostFrequentWord(self,arr,n)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n n = int(input())\n arr = [x for x in input().strip()... | eJzVVNtOg0AQ9cHE35jw3BhbY0x88s1fMHGNWWDdonR2hcUiRuNH6P86UNoAYVrE+iCQvZ25MHtO5uPw6+rooHquL2lx8+pFaDPnXYA3FXgmUIIPAYSgBHoT8FRuVeBUeGcyV9sR8k7g2wTazufkbG2swJdIL6w2OpF2c2QSiVqtEDZ+jfbmmJ4IDI2GQDpYmCxV1ap9Uu42KzZLhfXmmFEOlygF5TCvAvVsnbGtmYH3fMyW07DoLep0TU5jHMXArJSI5F0ZN1JWrYEtExt1DXOhc3iBAnIo2AjFFkFJnwSv7kHPI3h4jGGBBuxTAqnL... |
705,726 | Techfest and the Queue | A Techfest is underway, and each participant is given a ticket with a unique number. Organizers decide to award prize points to everyone who has a ticket ID between a and b (inclusive). The points given to a participant with ticket number x will be the sum of powers of the prime factors of x.
Examples:
Input:
a = 9
b =... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1703587839,
"func_sign": [
"public static long sumOfPowers(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 br = new Buffer... | {
"class_name": "Solution",
"created_at_timestamp": 1703239517,
"func_sign": [
"sumOfPowers(self, a : int, b : int) -> int"
],
"initial_code": "class IntArray:\n def __init__(self) -> None:\n pass\n\n def Input(self, n):\n arr = [int(i) for i in input().strip().split()] # array input\... | eJxrYJkqzcoABhEiQEZ0tVJmXkFpiZKVgpJhTB4IKekoKKVWFKQml6SmxOeXlkBllWp1FFAVGwER0YoNSVEMNNmYeJMNQJgks0EaDMDaDIj3riUIQHSC9UL5RmA+Ca6FaCdRG9AqqINhlpNjiqEpVDuQBgebuSmED6RJCEJkPxA0lTRPQtMgIqAtyQ9pQi6jLOGQkFHgiRRMkhLQyBpJ0gnKm6TnDbypjNRMDELERip5ngRHL6GciTX68aX22Cl6ACWzfWA= |
703,286 | Last duplicate element in a sorted array | You are given a sorted array arr[] that may contain duplicate elements. Your task is to find the index of the last occurrence of any duplicate element and return the index along with the value of that element. If no duplicate element is found, return [-1, -1].
Examples:
Input:
arr[] = [1, 5, 5, 6, 6, 7]
Output:
[4, 6]
... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int[] dupLastIndex(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.par... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"dupLastIndex(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().du... | eJyllE1OwzAQhVkgzvHkdYvGTuLEnIMFUotYQBZsQhepVAkhcQi4L/Y4oWniCTS1x0okj58+e34+r783N1c8Hu79z+ZdvTa7favuoPS20dAwyHjmKPy0agVVH3b1c1u/PL3t2865QrFt1McKIwGCN0PI2PLeCoJlK0kQ1GE7KclEkYaJUKKCg5OEDFwaLYDFlQ1WTgEvLkuBkFANliMROQsOc8xxBuZA3XGDH0nStH4vKSkcWGusdZpBOuJ3hAPjKQg4QYDwa2aSBUUwiUj7PSFoYWD8dTwENdO7iZCWeryTxFiQGucluRysmXsuuuWk... |
703,748 | The AND Gate | Given N bits to an AND - Gatefind the output that will be produced.AND - Gate Table:1 & 1 = 11 & 0 = 00 & 1 = 00 & 0 = 0
Examples:
Input:
N = 4
arr: 1 1 1 0
Output:
0
Explanation:
1 & 1 = 1
1 & 1 = 1
1 & 0 = 0
hence output is 0
Input:
N = 4
arr: 0 0 1 0
Output:
0
Explanation:
0 & 0 = 0
0 & 1 = 0
0 & 0 = 0
hence o... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int andGate(int arr[] , int N)"
],
"initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*;\n//Position this line where user code will be pasted.\nclass GFG\n{\n public static void main(St... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"andGate(self, arr, N)"
],
"initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n arr = input().split(' ')\n for itr ... | eJxrYJl6kZUBDCJOARnR1UqZeQWlJUpWCkqGMXmmMXmGChBooKSjoJRaUZCaXJKaEp9fWgJVZRCTVxeTp1Sro4Cq1Qyk1QCq2ZBEzYYGCIuRIA5TDHGYYhyTZwB0Aqkut4DYDXO7AWmux2UbsZ4k1bWGyHGEGWQkB72RAUrEKeAxm1STTbFGKj63k55woNYgrMId0DiDGld6QhgOBKQmRtJcRrU8gGwtuVrRCgIKTAInLTp53oD4nIiZ40nKhQqUepGc4CSgJ3aKHgD40KAF |
704,773 | Yes XOR No | You are given two arrays A[] and B[], each of size N, where each elementAiand Bjaredistinct. Let's consider an integerX is the countof all different pairs of Aiand Bj, such that AiXORBjis present in any of the two arrays. Return "Yes"(case-sensitive)ifX is even, else return"No".
Examples:
Input:
N =
3
A[] =
{1, 5, 7... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static String yesXorNo(int N, Long[] A, 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 ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"yesXorNo(self, N, A, B)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n A = list(map(int, input().split()))\n ... | eJy9VdtKxDAQ7YOsv3HI8yKZ3Nr6JYoVH7QPvsSF7YIgih+h36uT2B12XRRNy6ahPZDMmemZmeT15H1xWuVx8bGoqqsndR9Xm0GdQ1EXZaolVP+46m+H/u7mYTOMWy77dRdfePl5iX1Lw2bgl4UrsLbZGvxx8AgFDG5kSO6ZATWaAhYvLGCYWdCCdAFVMiK9HWi3Q1AjqBYUBHlBTpAVZATRTsSYHjATeSZhCgJZkAfVoJbzyw4Ck5MGGZADBVADU+SpiyJHWbV9xXrwpAX8POcXRScNkhIuq6JZoMBCmWkNNDZEcnAEZZLPQnWS6X6d... |
703,544 | Shop in Candy Store | In a candy store, there are n different types of candies available and the prices of all the N different types of candies are provided to you. You are now provided with an attractive offer.For every candy you buy from the store and get K other candies ( all are different types ) for free. Now you have to answer two que... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static ArrayList<Integer> candyStore(int candies[],int N,int K)"
],
"initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])throws IOExcep... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"candyStore(self, candies,N,K)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n\n for _ in range(t):\n N, K = [int(x) for x in input().split()]\n candie... | eJy1VMtOAzEM5ID4jtGeKxTnsdnwJUgs4gA9cAk9tBISAvER8Cnc+DjsbCtabRxRED1EWzkeezzjvJ6+f56dlN/lB39cPXX3ebVZdxfoaMxkkKYTAyJ6BHg4WHCsW6BbPq6Wt+vl3c3DZr3LApkxv3D8eYEZ2sAnpzuGCQwXGTaVBAXNgVINzY25hy2Q1sAZeINg0DNSkOb4MKAgQRvGHMEJ5AoFzzVdgwCD0ZaCmxD5y8NSrQ9uISHIMZsPEfoxWy7FfyXqGGSAtXyJmHQJ67RjKSe3rFJ4gC9EmWWA48oBgYcaELkhKWrqw5bSZNXa... |
704,100 | Coin Change (Count Ways) | Given an integerarray coins[ ] of size Nrepresenting different denominations of currency and an integer sum, find the number of ways you can make sum by using different combinations from coins[ ]. Note: Assume that you have an infinite supply of each type of coin. And you can use any coin as many times as you want.
Exa... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1731139025,
"func_sign": [
"public int count(int coins[], int sum)"
],
"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": 1731139025,
"func_sign": [
"count(self, coins, Sum)"
],
"initial_code": "# Initial Template for Python 3\n\nimport sys\nsys.setrecursionlimit(10**6)\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n coins = list(map(int... | eJyVlMFqwzAMhnfogwify7Dkyo72JIO19LDlsEvWQwqDMdhDbI/UWx9qshMoFClbQxx88P/nk34lX6uf8+quXY8n3Tx9hNfhcBzDAwTcDvWOMYY1hP790D+P/cv+7TheDoTPNVxJ9Lw+HUm0JBwjkC6VAuuJwt4baWPpCRIwFEAETIC6kcbhYXeYxUFvHEnXprHUStg16kwajlAYkLh6bYfkyrPJoLWoLTuaZGlE6pJbWz4n5ddHZrN5ak5uYn84TPEl6eWcTWYn5tnJs0pZSpdFSOzMpyJuGvHoDorvUyQRYiY79L9BzI7gcgQm/BwB... |
701,204 | Rotate and delete | Given an array arr integers. Assume szto be the initial size of the array. Do the following operations exactly sz/2 times. In everykth (1<= k <= sz/2) operation:
Examples:
Input:
arr =
[1, 2, 3, 4, 5, 6]
Output:
3
Explanation:
Rotate the array clockwise i.e. after rotation the array arr = [6, 1, 2, 3, 4, 5] and dele... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public static int rotateDelete(ArrayList<Integer> 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\nc... | {
"class_name": "Solution",
"created_at_timestamp": 1713200839,
"func_sign": [
"rotateDelete(self, arr)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input())\n\n while t > 0:\n arr = list(map(int, input().split()))\n ob = Solution()\n ... | eJzNlk1uE0EQhVmw4xJPs47Q9E/9NCdBwogFeMHGZOFIkRCIQ8A12bGnpp8tCErbcRRb1KimLbvnq3rV3TX+9vzHrxfPur3+GR/efJ4+bq5vttMrTGm1ad3g3WDdoN0g3VC7oXRD7obUDSmXKjpdYVrfXq/fb9cf3n262e7wxKw2X1eb6csV7gaWGZIgGVIgNWJBIqJBHNKgMzRBM7RAK1QiJ2hk5tAGm2EJlmEFVmEC08gdFgpCywxP8Awv8AoXuMItNMIb2oyW0DJaQatogqZohuaIOqR5Homp9wnJq01CCEAAsNSjIAmSITXkhBz1... |
703,036 | Smallest sub-array with all occurences of 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 with 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, 1 and 2.Th... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1618078978,
"func_sign": [
"ArrayList<Integer> 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 G... | {
"class_name": "Solution",
"created_at_timestamp": 1618078978,
"func_sign": [
"smallestSubsegment(self, arr)"
],
"initial_code": "if __name__ == \"__main__\":\n t = int(input()) # Number of test cases\n while t > 0:\n arr = list(map(int, input().split()))\n ob = Solution()\n r... | eJy1Vs1OhDAQ9uDJp5hw3hiGlrb4JCZiPCgHL7iH3cTEaHwIfR1vvpfTAVxAZ7flp99MyrbMx9eh0+X9/PP74ozb9Rdd3Lwkj/V2v0uuIMGyVqBAE3KGIViGa5BsIKmet9X9rnq4e9rv2sB2Fsr6rayT1w0MSREyps2ZzkEBmAIiYAaoADVgDmgALaADLCBLIaPZPoQHL8AsiS6gQbMy+wvD8NnRDEUSPI7JPERLGUpJGLki1+Q5OfZc9Vz3PD+4lKETzKIgn8mMTbFptpzNsFk2x1aw9YmbkWaW7xQESpFReyliMHYzxVEfecG+QdcX... |
704,103 | Sequence of Sequence | Given two integers m and n, try making a special sequence of numbers seq of length n such that
Examples:
Input:
m = 10
n = 4
Output:
4
Explanation:
There should be n elements and
value of last element should be at-most m.
The sequences are {1, 2, 4, 8}, {1, 2, 4, 9},
{1, 2, 4, 10}, {1, 2, 5, 10}.
Input:
m = 5
n =... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int numberSequence(int m, int n)"
],
"initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])throws IOException\n {\n Buf... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"numberSequence(self, m, n)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n arr = input().split()\n m = int(arr[0])\n n = i... | eJxrYJmaz8IABhEZQEZ0tVJmXkFpiZKVgpJhTJ6hgYGCoZKOglJqRUFqcklqSnx+aQlM2sAgJq8uJk+pVkcBTZcCUA6HLpx6QDaRrMvUQMGUVD2WlgpGOLQYmZji0mWkYGlJhpdI1gR0HTmBB9REqh7cEYvPFgMy45eMiAIGOcQyIEFWKJIRYwgfIhxgADaQzFghL+UoGJBnHcLnBGw2JCbQSQ11SIIH20xAZ+wUPQCtwVp7 |
709,949 | Maximum product subset of an array | Given an array arr. The task is to find and return the maximum product possible with the subset of elements present in the array.
Examples:
Input:
arr[] = [-1, 0, -2, 4, 3]
Output:
24
Explanation:
Maximum product will be ( -1 * -2 * 4 * 3 ) = 24
Input:
arr[] = [-1, 0]
Output:
0
Explanation:
Maximum product will be... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1720001770,
"func_sign": [
"public long findMaxProduct(List<Integer> arr)"
],
"initial_code": "import java.util.*;\n\npublic class GFG {\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n int tc = sc.next... | {
"class_name": "Solution",
"created_at_timestamp": 1720003500,
"func_sign": [
"findMaxProduct(self, arr)"
],
"initial_code": "# Initial Template for Python 3\n# Position this line where user code will be pasted.\nif __name__ == \"__main__\":\n import sys\n input = sys.stdin.read\n data = input()... | eJyVVEsKwjAUdNGDPLJuJEk/Vk8iGHGhXbiJLloQRPEQeg53ns8krQWlE9sQaCCdmbw3k9yixyua+LF82sXqzPbmWFdsQUxqo7QRJFhMrDwdy21V7jaHumr3hTZXbdglpm9Qog2X5CdASoDMnZwDKrLfBCrnIWXHICgD0EygY0sPBjC7g8/cSgpqF5BFCjeQvvB9U67wlHhGOfEZFcTnmDDJVVFARu9e4DAAlnrTnQPIvwDSWveZSBe553RHCvrmj62vSUnneDAu9r9eGj4DACAHYxUobHisgrlqqDC0tzzUj97yuofip6coAWrg9ef/... |
701,209 | Maximum Index | Given an array arr of positive integers. The task is to return the maximum of j - i subjected to the constraint of arr[i] < arr[j] and i <j.
Examples:
Input:
arr[] = [1, 10]
Output:
1
Explanation:
arr[0]
<
arr[1] so (j-i) is 1-0 = 1.
Input:
arr[] = [34, 8, 10, 3, 2, 80, 30, 33, 1]
Output:
6
Explanation:
In the ... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1720036233,
"func_sign": [
"int maxIndexDiff(int[] arr)"
],
"initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(... | {
"class_name": "Solution",
"created_at_timestamp": 1720053240,
"func_sign": [
"maxIndexDiff(self, arr)"
],
"initial_code": "# Initial Template for Python 3\n\nimport math\n\n\ndef main():\n T = int(input())\n while T > 0:\n arr = [int(x) for x in input().strip().split()]\n ob = Soluti... | eJytU8EKglAQ7FD/MbyzhM/UtC8JMjqUhy7mQSGIoh/oZv/bpk+iZNXV9iE80JmdGXfv02cxm5S1ftBlc1HHJM0ztYLSUaKVBRWf03ifxYfdKc/MKztKblGirha+v3cgRWg4WMCFBx9LBAihbYYi5ChsQgWE9onFJTa5Cg+NIxVBuutioFoQQQcVH0VdoyMhQ+Y4DNJr8fPzCG0QpjQjDbJy/XY7xC6NgWn8sd7LRreeyg6vyuUYegr7wwqIW5WWxswXTT2R0cy3zzqbDQ/hezZXzfwb8aYNjMu065PYtpi/AHyKjAQ= |
705,138 | C++ Matrix Rotation by 180 degree | Given a square matrix of size N X N, turn it by 180 degrees in anticlockwise direction without using extra memory.
Examples:
Input:
N = 4,
matrix = {{1, 2, 3, 4},
{5, 6, 7 ,8},
{9, 10, 11, 12},
{13, 14, 15, 16}}
Output:
{{16, 15, 14, 13},
{12, 11, 10, 9},
{8, 7, 6, 5},
{4, 3, 2, 1}}
Input:
N = 2,
matrix =
{{1... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public void rotateMatrix(int[][] mat)"
],
"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 IOExcepti... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"rotateMatrix(self, mat)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n = int(input())\n matrix = []\n for _ in range(n)... | eJztm82uJEcRhVnwCuxYpGZtoYqMjMoungSJQSzACzYXL2wJCYF4CHhfvhMVY90701V9f3owHg2N7NFUdFZWfJHnRGaX//XL//x6+0X+73e/4g+///u7vzx898P3737b3tn7B/3/3Tft3bd/++7bP33/7Z//+Ncfvv9wtb1/+Of7h3f/+KY9/U5//7C0Jf9x8FWutLx+NIS/f9japc33D2uLNviL1tvxRHpzRhqErvx78s3taOTggVp9XvLHw3t/+DyKfeafr85vVYyeJ5/mw8PY0owvkVnzZqNZNFubzWYX/mprfWmdr/XWSRTp6tH6... |
705,051 | Recursive sequence | A function F is defined as follows F(n)= (1) +(2*3) + (4*5*6) ... upto n terms (look at the examples for better clarity). Given an integer n,determine the F(n).
Examples:
Input:
n = 5
Output:
365527
Explanation:
F(5) = 1 + 2*3 + 4*5*6 + 7*8*9*10 + 11*12*13*14*15 = 365527.
Input:
n = 7
Output:
6997165
Explanation:
... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static long sequence(int n)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG{\n public static void main(String args[])throws IOException\n {\n BufferedReader ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"sequence(self, n)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n\n ob = Solution()\n print(ob.sequence... | eJylVMFOwzAM5YD4jqlnhGI7dmx+gwuCIA6wA5eywyYhIRAfAf9Lmq6CjSWpWA9R08bP7z2/9uP06+bsJF/XV+nm9rV76lebdXe56Cj2HPsQe3Cx784X3fJltXxYLx/vnzfr6YwwYzryHnsxCyCc71FVTILHvOvezhe/cNNDdgNqGZaJ1AM6yfWMZGJ+22cPDWJvZmWCjsgpukJpIlFhoQHBkOhQcRKKQy0Nix8Wdq4BCI6FAqmNhpGCJ0HNOzN2AGiQdxAcIwQe31WJDCrKHQsVXGO50/vv8Fq2wSzOZlpEEKZgJigFBjbkxyoUkNQl... |
700,255 | Topological sort | Given an adjacency list for a Directed Acyclic Graph (DAG) where adj[u] contains a list of all verticesv such that there exists a directed edge u -> v. Return topological sort for the given graph.
Examples:
Input:
adj = [[], [0], [0], [0]]
Output:
1
Explanation:
The output 1 denotes that the order is valid. Few valid... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1729069893,
"func_sign": [
"static ArrayList<Integer> topologicalSort(ArrayList<ArrayList<Integer>> adj)"
],
"initial_code": "import java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass Main {\n public static void main(String[] args) throws I... | {
"class_name": "Solution",
"created_at_timestamp": 1729069893,
"func_sign": [
"topologicalSort(self,adj)"
],
"initial_code": "# Driver Program\n\nimport sys\n\nsys.setrecursionlimit(10**6)\n\n\ndef check(graph, N, res):\n if N != len(res):\n return False\n map = [0] * N\n for i in range(N... | eJy9lEGOwjAMRVmMOIeVNUJOQqFwEiQ8mgXTBRsPiyIhIRCHgFux40LTpKGFER3qIMimkVL7fX9b3n8cz92OP9NTcZlt1IKXq1xNQGniBDQSIxhiA5bYwoB4AIl7GRIPYUQ8gpQ4hTHxGIoQDUWE6oHK1stsnmffXz+rvM64Kx63PbjFeADGRptW0dgQrcELkGOtMyRgTahBksIE6+oU9y3G/3OXdTWJ9B1CuHisHcFUBFthhLX7dj8S7slpqFII0Bgm7yHievzk3U9u/bmm6GCXRLmT3PC/lC00rEUh9tkBR+GESxcIxW4AKSWEuE/M... |
703,915 | Palindrome | Given an integer, check whether it is a palindrome or not.
Examples:
Input:
n = 555
Output:
Yes
Input:
n = 123
Output:
No
Constraints:
1 <= n <= 1000 | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1618912397,
"func_sign": [
"public String is_palindrome(int n)"
],
"initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG\n{\n public static void main(String[] args) throws IOException\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1618912397,
"func_sign": [
"is_palindrome(self, n)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n = int(input())\n ob = Solution()\n ans = ob.is_pa... | eJytlMFOhDAQhj0Yn4P0vDGlLUL3ITxrHONBOXiZ3UQ2MdlofAh9F2++mtNBNmBLW7LbUOiBfMz/z898nH/9XJzxuvmmw91ePON214l1ISrAki63JR/4JEuxKkT7um0fu/bpYbPr/l6/bV8AQ7d3QPG2KkZkA1g3NaAqFaDWGtBauwDrEwlRKrppxZXKGdj1BnDYPoQES5ZI9TQWsJFNsjJHytJbk15j6FRV1WIfw4IdhlGpAmflEsL2FMvPOGoqOAzVPYZ9I62zwARGuX46gUqlfQpKU0O0zOC68/2K12kS7Hd0musFqY6ZEHfh4GM8... |
704,744 | N Digit numbers with digits in increasing order | Given an integer n, print all the n digit numbers in increasing order, such that their digits are in strictly increasing order(from left to right).
Examples:
Input:
n = 1
Output:
0 1 2 3 4 5 6 7 8 9
Explanation:
Single digit numbers are considered to be
strictly increasing order.
Input:
n = 2
Output:
12 13 14 15 16 ... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public static ArrayList<Integer> increasingNumbers(int n)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass IntArray {\n public static int[] input(BufferedReader br, int n) throws IOException {\n S... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"increasingNumbers(self, n : int) -> List[int]"
],
"initial_code": "class IntArray:\n\n def __init__(self) -> None:\n pass\n\n def Input(self, n):\n arr = [int(i) for i in input().strip().split()] #array in... | eJztmFFrZFUQhH3wXwhyGfBtEav63DuJv0RwxAfNgy9xH7IgiOKP0P9rVfWZTSKZyUZYlsAsXHLn5Haf6vr6TPruX5//89UXn+Xfd1/q5vvfd7/cvn13t/t22eFwW7s3y+7mt7c3P93d/Pzjr+/ujr9iLeDQteradO11Xem6XlBaL62X1kvrpfXS+tDa0NrQ2tDa0Nqqz6s+r/q86vOm+033m+73+rnXz6vrhcpJ5aRyUjmpnFROKieVk8pJ5aRyUjmpnFROKieVk8pJ5aRyUjmpnKXYUmwpthRbii3FlmJLsaXYUmwpthRbii3FlmKH... |
712,032 | Pattern 15 | 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:
5
Output:
ABCDE
ABCD
ABC
AB
A
Constraints:
1<= N <= 20 | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1662630404,
"func_sign": [
"void printTriangle(int n)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass Main {\n // Driver code\n public static void main(String[] args) throws Exception {\n BufferedReader br =\n new Buff... | {
"class_name": "Solution",
"created_at_timestamp": 1663311159,
"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... | eJzs29m2ZWeCnmUOuJAayakPcv5tiDP6HtNjcIKJTmCadAFVYDD24I64RbLeKrCqlJIjU4pQROxnDOmPvZcUn2LMOfe71sGj//uf/zv7X/h//rm/+49+9fd/+6d//me/+hf/5FfPb377/Opv/cmv3v/DP33/9s/ev/t7/+DP/+yv/tG/9Jvf/pPf/PZX//hv/clf//fHr3/oN/zL/8q/+q/96//Gv/lv/dv/zr/77/37f/s/+A//o//4P/nNb3/Pq7/vxd/z2vdf+t4rf/OFv/H9X//2r3333W++8/U//fL//+r/++Kvfv3LXzr/4vjd... |
713,197 | Min operations | Given two numbers aand b. In one operation you can pick any non negative integer x andeither of a or b. Now if you picked a then replace a with a&x else if you picked b then replace b with b&x.
Examples:
Input:
a = 5, b = 12
Output:
2
Explanantion:
In first operation replace
a = a&4 = 4
after that replace
b = b&6 ... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1671618896,
"func_sign": [
"public static int solve(int a, int b)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(... | {
"class_name": "Solution",
"created_at_timestamp": 1671618896,
"func_sign": [
"solve(self, a : int, b : int) -> int"
],
"initial_code": "if __name__ == \"__main__\":\n t = int(input())\n for _ in range(t):\n a = int(input())\n b = int(input())\n obj = Solution()\n res = ... | eJzdVk1LxDAQ9eDRH1F6XiST73r35g8QjHjQHrzEPeyCIIo/Qv+v03SzTXeTtvYDVodShrTMy7x5eeTz/Pvm4szF7TUmd2/5s11vN/lVljNjgTIupNKFsYVWUnBGwVhBdmGsbFIKXHHNJFftPF9lefm6Lh835dPDy3azq06N/cAf3Zu4d/6+ygJ46uDrx1gErh9MfRjLfQyCOQDgDrjwgX35aFIZ9CKCHNfBBy77SG4Dgm10bKnqmTSUhnnAfzCVBBxJQyBrvpIbGqkLB2AtTnyTpNXwALIhAU5q1ptuSFxmnZ1B51QTqnUt4wKq1uft... |
713,152 | Maximum Weight Node | Given a maze withN cells. Each cell may have multiple entry points but not more than one exit (i.e entry/exit points are unidirectional doors like valves).You are given an array Edge[] of N integers,where Edge[i] contains the cell index that can be reached from celli in one step. Edge[i] is -1 if the ith cell doesn't h... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1671445648,
"func_sign": [
"public int maxWeightCell(int N, int Edge[])"
],
"initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG{\n static class FastReader{ \n BufferedReader br;... | {
"class_name": "Solution",
"created_at_timestamp": 1671445648,
"func_sign": [
"maxWeightCell(self, N, Edge)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n for _ in range(int(input())):\n N = int(input())\n Edge = [int(i) for i in input().split()]\n... | eJytlL0KwjAURh36IJfMrSTpj9XVzScQvOKgHVyuHVIQRPEh9H29rdWCNZIUk6XDd06Tj0uuwX0RjJq1nPPH6iT2VFZGzEAopBQpUiCfW4QgimNZbE2x2xwq08Yk0gVJnEPosQm024ImFlTJ9r8KNMQsSCGDCeQWTf5DM4WcyYwNCZs0G33voVkEkbJQ6htlTfftcW3X3ofKuN+uH996kQaUID1LqCnw7852ss+YdA0i8SB4hBEV8pKv8R9ANijqbv7/oHKuxblA5xl9vwIuz8D6Nn4AXdZMTQ== |
701,749 | Nth number made of prime digits | Given a number 'n'. The task is to find the n**th number whose each digit is a prime number i.e. 2, 3, 5, 7. In other words, you have to find nth number of this sequence: 2, 3, 5, 7, 22, 23 ,... and so on.
Examples:
Input:
n = 10
Output:
33
Explanation:
10
**th
number in the sequence of numbers whose each digit is ... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1619248034,
"func_sign": [
"public static int primeDigits(int n)"
],
"initial_code": "// Initial Template for Java\n\n/*package whatever //do not write package name here */\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void ... | {
"class_name": "Solution",
"created_at_timestamp": 1619248034,
"func_sign": [
"primeDigits(self,n)"
],
"initial_code": "# Initial Template for Python 3\n\nimport math\n\nif __name__ == '__main__':\n t = int(input())\n for tcs in range(t):\n n = int(input())\n ob = Solution()\n ... | eJy9k7EKwjAQhh36ICFzkSYhhPgkghEH7eASO6QgiOJD6Ou4+V6eaTtk+K/gYOnQkn797/77714939UiX+sXPWwu8hi7PsmVkCpEumUtZHvu2n1qD7tTn8ZDHeKNDq+1KAkNCQMIizWQiMKMtYAxDdaxsDYMGYcgh6tzBpWnGqY+7RzAvOcoLIbbQl3RLNSMI4yJbJawlWocNpkTFMRRm1n4F1nveWut1TBn0yyZjMJYf9HCsLJ/ehl+HIqP/iXDbjcS88OGzxiqNbMYWZ3L3TTG7WP5Abeog8w= |
713,587 | Count number of free cell | Suppose you have a Matrix size n*n, and given an integer k and a set of coordinates arrof sizek*2. Initially, the matrix contains only 0. You are given k tasks and for each task, you are given two coordinates (r = arr[i][0],c = arr[i][1]) [1 based index r and c]. Where coordinates (r,c) denotes r**throw and c**thcolumn... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1673952736,
"func_sign": [
"long[] countZero(int N, int K, int[][] arr)"
],
"initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*;\n\npublic class GFG {\n public static void main(String[] args) throws Exception {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1673952736,
"func_sign": [
"countZero(self, n, k ,arr)"
],
"initial_code": "# Initial Template for Python 3\nfor _ in range(int(input())):\n n, k = map(int, input().split())\n arr = []\n for i in range(k):\n x, y = map(int, input().split(... | eJzNVktOwzAQZcGGW4yyrlDsOP5wEiSMWEAXbEwXrYSEQBwCjsWOA+E3rlOI8lHTD/UiGjvzeTPzPMn7+ef3xRmv668o3LwUj2GxWhZXVAgfBOVHMaNi/ryY3y/nD3dPq+VapyQf3uLb1xm1LEuqsn1JovShprrXjRWkFSnX541t2Zkk6UMF31F/2KnQ5EiRoCGQQCbSs6QcqRXEkPHBkvXBkWusxlKpNMmaGhCiHwQWwjos2hxJQONDQEqHEWFST5seELCx0Ej2GqJiUUF0LEq81yziMIIdRiibfvI249kKwnCEqpWdaILkmNMzHqOA... |
700,589 | Range of Composite numbers | Given an integer n, we need to find a range of positive integers such that all the number in that range are composite and length of that range is n. You may return anyone range in the case of more than one answer.
Examples:
Example:
Input:
2
3
5
Output:
1
1 | geeksforgeeks | Easy | {
"class_name": "GfG",
"created_at_timestamp": 1615292571,
"func_sign": [
"ArrayList<Integer> range(int n)"
],
"initial_code": "import java.util.*;\nclass Composite{\n\tpublic static boolean[] prime=new boolean[1500000];\n\tpublic static void main(String[] args){\n\t Scanner sc=new Scanner(System.in);\... | {
"class_name": null,
"created_at_timestamp": 1615292571,
"func_sign": [
"Range(n)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n\n for _ in range(t):\n n = int(input())\n\n print(range(n))\n print(\"~\")\n",
"solution":... | eJy9VcFKxDAQ9eDJryg9KRSZTJrd1i8RrIhoES9xkS4IovgR+lXe/CLTpHW7mYlNK7aQphnSmcx7kzdvhx9fRwf2Of80HxfP6b3ebJv0LEnzSgswQ1UazYwqzZK0ftrUN019e/Wwbbp9j9f6rj6GLBFwUunXSu8MyjOgvwO7HelLlgxCy0oXJjKasRqLWvhB0Tes2BgmLWnSUmasVZuqzRXGwkk/BeUb1n7WxjUBBtgztQmDaF8RYAsShgfTOrXZQYxbelgIODYslWVp/dpagXLMu9lOnefUVLLxRMsWjDKkflLgGLdItJNbCbcSboUR... |
703,288 | Sum of f(a[i], a[j]) over all pairs in an array of n integers | Given an array arr[]of positive integers, find the sum of f(a[i], a[j]) of all pairs (i, j) such that (1 <= i < j <= n).
Examples:
Input:
arr[] = [6, 6, 4, 4]
Output:
-8
Explanation:
All pairs are: (6 - 6) + (4 - 6) + (4 - 6) + (4 - 6) + (4 - 6) + (4 - 4) = -8 return -8.
Input:
arr[] = [1, 2, 3, 1, 3]
Output:
4
E... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public static long sum(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 this line where user code wi... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"sum(self,arr)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n tc = int(input())\n\n while tc > 0:\n arr = list(map(int, input().strip().split()))\n ob = Solution()\n ... | eJy9VMFOhDAQ9eDBrzATEm+LYdpOKX6JiRgPysEL7oFNTIzGj9D/tZ1hBV2KgGSnTV9Jad9j5pX308+LsxOO63M/uXlJHuvtrkmuINFljRko7shd5po7Zn4ZlG/aN+Mb+WbDHg4oOAScQC5gBSjZQFI9b6v7pnq4e9o1LS9af/RbWduCIdXymLxuoKdOdUwRLOu+hGGISBDGQd6QFaUNWbBktEIYefKvcoDiAM0BhgOIo1UJLgTkIcCGkPVYjqhQVBALlMNFbNqb/xLu1ZDkhwEFlIAWMAIkYAVyAScQSxmSjZWpK8y0mVTWWy0LTvOD... |
705,629 | Check if it is possible to convert one string into another with given constraints | Given two strings S and T, whichcontains three characters i.e 'A', 'B' and '#'only. Checkwhether it is possible to convert the first string into another string by performing following operations on string first.
1- A can move towards Left only
2- B can move towards Right only
3- Neither A nor B shouldcross each otherNo... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int isItPossible(String S, String T, int M, int N)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"isItPossible(sef, S, T, M, 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 S, T = input().split()\n ob = Soluti... | eJy1VL0KwjAQ7mB9jpCsRezq1jyFYMVBM7jEDi0IovgQ+rpiepecEVswibY0vQz33ffd33Vyz6cZPMtHnmWrE9/rpmv5gvGy1kJUQkjz4p8Ja5jDnLxgXB0btW3VbnPoWus3r/Wl1vxcsHcw8OwBAKiKhQEfcDcw0jEKRsH4+DH/EggkPSQWD+NkCNSFZpwySnFPJFgNhsbMjgcvx4KjeCiQMSCxaMb0i61zLwYuAB6hiCQl1dniEJDLFQD+pI3ddMmYuhPBQXap8gfphpP0awo88Bou1e6ll7KEsfUqSoz+0CE0Hp/z4XqbRiVttwIJ... |
702,888 | Bird and maximum fruit gathering | There are several trees arranged in a circle, each with a fruit value associated with it. A bird can gather all the fruits from a tree by sitting on it for 0.5 seconds and can move to a neighboring tree in another 0.5 seconds. Once all the fruits are picked from a tree, the bird cannot pick any more from that tree unti... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1617892345,
"func_sign": [
"public int maxFruits(int[] arr, int totalTime)"
],
"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[] ar... | {
"class_name": "Solution",
"created_at_timestamp": 1617892345,
"func_sign": [
"maxFruits(self, arr, totalTime)"
],
"initial_code": "if __name__ == \"__main__\":\n t = int(input())\n for _ in range(t):\n totalTime = int(input())\n arr = list(map(int, input().split()))\n solution... | eJytU8tKA0EQ9KD/Ucw5SPc8Nhu/wpuCKx50D17GHDYQEMWP0P91ejeERKiJK84wMOxS1TVV3R/nXzcXZ+O6vS6Xu1f3nNebwV3BaZdV7GCFFks0SIgI8FC3gOu36/5x6J8eXjbDDpFSl9+77N4WOOYp3wXTVhEhcPtFCGLhEERBEHiKjwzelGcU3aHoT2gI3CtBt6W+4aa3mxuEIbSEYdnlgIM9V8HK9P/YFRuZDG9p2jpmqsQhTJEmO9AIDdBiiyn6daOoryU16tulxQiUtdokrP2rMt8ERjzOAvWqkhzD0EIa/mHsmFRiWaRWR2q1... |
703,990 | Maximum Product Cutting | Given a rope of length N meters, cut the rope in different parts of integer lengths in a way that maximizes the product of lengths of all parts. You must make at least one cut. Assume that the length of the rope is more than one meter.
Examples:
Input:
N = 5
Output:
6
Explanation:
Maximum obtainable product
is 2*3
I... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int maxProduct(int n)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nclass GfG\n{\n public static void main(String args[])\n {\n Scanner sc = new Scanner(System.i... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"maxProduct(self, n)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n = int(input())\n ob = Solution()\n ans = ob.maxProdu... | eJy1VMtqFFEQdSF+x9DrIPV++CUBR1zoLNyMWUwgEBLyEeYL3PmVnp5RhEA1LvRu+kJ31anzqH56/fzjzavzuf6Oy/v75cvx5va0vNstvD8yLVe75XB3c/h0Onz++PX29Oudxv74uD8uD1e7FxU+VIjpUCITCJvXVDPBVNpUoxOON1lPRROQuknbUGUTlLB4xlg2gbGpVVMOdT7BVVCrmUx4PSmS2h4yKulbFkS4e2uSakWWSFBWu1uLMXVYSbsSZ7CXWqrjE44pHk5bDC2zSFPlAupF1Awg80whBZqJR7axluNhxlUaqgobvNNTMIRS... |
703,281 | Countries at war | The two countries of A and B are at war against each other. The power of these soldiers is given by arr1[i] ofA and arr2[i] of B. They can only attack their counterpart enemies like arr1[i] can attack only arr2[i] and not anyone else. Both countries have equal number of counterparts. A soldier with a higher power can k... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public String countryAtWar(int[] arr1, int[] arr2)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass Main {\n public static void main(String args[]) th... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"countryAtWar(self, arr1, arr2)"
],
"initial_code": "# Initial Template for Python 3\nimport io\nimport sys\n\n# Contributed by : Nagendra Jha\n\nif __name__ == '__main__':\n test_cases = int(input())\n for cases in range... | eJxrYJn6jZUBDCLeAxnR1UqZeQWlJUpWCkqGMXlAZBCTp6SjoJRaUZCaXJKaEp9fWgKVd4zJqwNK1uoooGoyAOvDockJhyZDAxBQAOo1UICwcRrhEuQYjsMUSxCA6ocbA+VC5MAkyV5CNYoclxkqQCHIg1BIesgidCKZR2pIGxmbmCqYmVtYAoMIwUaWMERIWOAOLDy+NcCXbvCFEshakAuAUWlhbmZqYmxEugeJSgTIfsaTIHAGIq7IgNiD29FYoxZ3WBHlOyqlcXxJA5EYwIbTI0YQVpNVlMBTIUwgj/QQgQUBjE1pjsHpYiyFAyy4... |
702,710 | Maximum Gap | Given an unsorted array arr[] of positive elements. Your task is to find the maximum difference between the successive elements in its sorted form.Return 0 if the array contains less than 2 elements.
Examples:
Input:
arr[] = [1, 10, 5]
Output:
5
Explanation:
The maximum difference between successive elements of array... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int maxSortedAdjacentDiff(int[] arr)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n // Driver code\n public static void main(String[] args) throws Exception {\n BufferedReader br = ne... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"maxSortedAdjacentDiff(self,arr)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n tc = int(input())\n while tc > 0:\n arr = list(map(int, input().strip().split()))\n ob = ... | eJyVU7EKwjAQdeiHHJmL5FKqiV8iWHHQDi61QwVBBHc30f+1TYq1kpeSWxK4e/fu8l7uyfuZzGysH+1lcxXHqj43YkWCi4pFSqK81OW+KQ+707npU7KoxC2lv2JJLG0AlOkCQG0Q4rNI40MqUlEzEkMSBOhnQzx2NB3GZuQ2CLVY+FpkpCknQ6yIc4DOQi/qeN2h3bEEfdi/Q95LE5TWFXkFinvtMRt0EuZjOYFFBowpb10Xbb1BSqgkK+l1gZMN87l8iPXbBHTQfhO1OnTbjkz8sz7yM/ulMZPfXA4fffuafwDGk1E+ |
703,480 | K-th missing element | Given an increasing sequence arr, we need to find the K-th smallest missing element, taking the first element of the array as the starting point in the increasing sequence. If there is no k-th missing element then output -1.
Examples:
Input:
arr[] = [1, 3, 4, 5, 7] and k = 2
Output:
6
Explanation:
k = 2, Missing num... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int KthMissingElement(int arr[], int k)"
],
"initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass GFG {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"KthMissingElement(self,arr,k)"
],
"initial_code": "# Initial Template for Python 3\nif __name__ == \"__main__\":\n t = int(input())\n while t > 0:\n k = int(input())\n arr = list(map(int, input().split()))\... | eJytU7tOxEAMjBDwHaPUB/I+nOzyJUiAKCAFzd0VOQkJgfgI+FoabOcoQCzhkqysaSzPeuzx6/H70Wll7/LjpKqunuqH9XbX1xeo3fV6iHqFunvcdnd9d3+72fX7/JmkXiT7vMKPKtI3rVQCX/WFYl/8Vos9AiIYDVokZLgyUbGLLE/JCJ4QCJHAhIbQEhIhk7Y4ZS4DtYOiNwyG0ZANG8PWMBnmsYkUf2Taz1OEqBKVolpUjKpROarHBJX5+a91TWwtf1/WsCo46dbDBbgIx4ezBmUNwqdcDC9fJIQGkcFlOh7xQVraCBJLm+cwx1g6... |
703,260 | Sum of distinct elements for a limited range | Given an array, arr[] such that every element of the array is an integer in the range 1 to n (n is the size of arr), the task is to find the sum of all the distinct elements of the array.
Examples:
Input:
arr[] = [5, 1, 2, 4, 6, 7, 3, 6, 7]
Output:
28
Explanation:
The distinct elements in the array are 1, 2, 3, 4, 5,... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int sumOfDistinct(int[] arr)"
],
"initial_code": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int t = Integer.pars... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"sumOfDistinct(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... | eJyVk01OxDAMhVnAPZ6yHqHaqZuakyAxiAV0wabMopWQAIlDwH1J0yLxY8+06aJVY/vZX17ezz9fL87Kuh7zx81LeOwP4xCuEGjfU1UWwg6hez5090P3cPc0Dt8R8/a+D287/Ml0c6xo9qLZrL2lNIERUUPQIKGFgionX8QssDDQsuZXi99/ve7LZrLbWp5NsxRBZHlN0AYq0BoaoQz1KqkzlsEFlBtiUATVIAE1oATK0yrYo8ZkGkBy9UlDigpPSt6oZn8ZrhPv+G3GeYSo6aUqujrRcbZ9CJ5sSqfx/MdVeB1hJvbFUNfb09ZWG6zv... |
706,421 | Minimize the Heights I | Givena positive integer k and an array arr[] denoting heights of towers, you have to modify the heightof eachtower either by increasing or decreasing them by k only once.Find out what could be the possibleminimum difference of the heightof shortest and longest towers after you have modified each tower.
Examples:
Input:... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1727078372,
"func_sign": [
"public int getMinDiff(int k, int[] arr)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws IOException {\n BufferedReader br = new Buffe... | {
"class_name": "Solution",
"created_at_timestamp": 1727077270,
"func_sign": [
"getMinDiff(self,k, arr)"
],
"initial_code": "# Initial Template for Python 3\nif __name__ == \"__main__\":\n t = int(input())\n for _ in range(t):\n k = int(input())\n arr = list(map(int, input().strip().sp... | eJzNVsGO1DAM5cCJr7B6XqE4TdqEL0GiiAPMgUvZw6yEhEB8BHwSNz4Kv5dMZ6VOSncWEB3F9SSOn2M7T/369PvPZ0/4vPxhyqtP3fv59u7YvZCun2Z19pSXRAhOiFL3ZTHbAxPJVZtmm+1upDt8vD28PR7evflwd6w+uXOav0zzaMZKrfzvPt/IPXA/zcVUAawEVgLrOaw66yl7x7UG8IJb964Rz36jO52X4M5T9pShiRAuOQ0lH2JBSi9BogwySpJsoYvaAbxoLxrsZKKD6CiaRLMdCdGU5Coz6yl7ykAZKQfKkTKVGpQq8SDT7FGp... |
709,994 | Insert an Element at the Bottom of a Stack | You are given a stack st of n integers and an element x. You have to insert x at the bottom of the given stack.
Examples:
Input:
n = 5
x = 2
st = {4,3,2,1,8}
Output:
{2,4,3,2,1,8}
Explanation:
After insertion of 2, the final stack will be {2,4,3,2,1,8}.
Input:
n = 3
x = 4
st = {5,3,1}
Output:
{4,5,3,1}
Explanation... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1689770418,
"func_sign": [
"public Stack<Integer> insertAtBottom(Stack<Integer> st, int x)"
],
"initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n static File file;\n static BufferedReader in;\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1689786026,
"func_sign": [
"insertAtBottom(self,st,x)"
],
"initial_code": "if __name__ == \"__main__\":\n for _ in range(int(input())):\n n, x = map(int, input().split())\n stack = list(map(int, input().split()))\n obj = Solution(... | eJzNVjtOw0AQpaDkEE+uI2Tvx7vmJEgYUUAKGpMikZAQiEPAYeg4GruOZ+zIHscBYpg0z5Hn43kzb/f19P3z7KS2y48Arp6S+2q1WScXSLKyylJkKVlZFWQg4Bk5Rjkjy8gw0owUo4xRmiyQLB9Xy9v18u7mYbOmWrgKfvWIRaCsXsoqeV5gtx0Wtm2G4Yo0I8WIC4YnJHwah8TBEaU6I21KG5s7XwTWvMut0SoDgRQEChDwIOBAIAcBCwIGBEITm4ASaVQDjl+CTFka+9FvZ9vitu1MhfBBXRImRhqhiAc5PKH3E0pop3/AZyRZZ3AH... |
703,957 | Absolute Difference of 1 | Given an array arr. Return all the numbers less than kand the number which have at least two digits and the absolute difference between every adjacent digit of that number should be 1in the array.
Examples:
Input:
arr[] = [7, 98, 56, 43, 45, 23, 12, 8], k = 54
Output:
[43, 45, 23, 12]
Explanation:
43 45 23 12 all the... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1617817733,
"func_sign": [
"public ArrayList<Integer> getDigitDiff1AndLessK(int[] arr, int k)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass Main {\n public static void main(St... | {
"class_name": "Solution",
"created_at_timestamp": 1617817733,
"func_sign": [
"getDigitDiff1AndLessK(self, arr, k)"
],
"initial_code": "# Initial Template for Python 3\n# Position this line where user code will be pasted.\n\nif __name__ == \"__main__\":\n t = int(input())\n\n while t > 0:\n ... | eJy1Vs1OwzAM5sCFt7B6nlD+m/AkSBRxgB24FA6bhIRAPAS8Djfei89O0Da0ZK201aq1drY/+4vj9OP86+fiTK7rb/y4ee0ex+f1qruiTg+jVmoYjSXryHnygUJPfaSYSBsymqwhZ8m7YewW1C1fnpf3q+XD3dN6VWJM8n2H+9uCdqE9Q2ulYWpga2HsYO0pIFSPWBHBEkfTChF1NYX/McR2LySqZUzYGdhZYDlgeWAFYPXAiklT4vTxP79LKdVxG3GKfz2PYYyw9syQFbYAmuCLMI7faFXFPey4F9Tk4jXIMiDLgiwHwj0IDyC8B+FR... |
703,387 | Smallest Non-Zero Number | You are given an array arr[]. Your task is to find the smallest number x such that when x is processed sequentially with each element of the array (from index 0 to n-1), it never becomes negative, under the following conditions:
Examples:
Input:
arr[] = [3, 4, 3, 2, 4]
Output:
4
Explanation:
Start with `x = 4`:
- For... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int find(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); // Initialize scanner for input\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"find(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]) # Read the number of test cases\n\n results = []\n for i in... | eJzdVcuKwkAQ9ODJrxjm5EF0onm0+yWCWfagOXiJHiIIy4of4f6vXRERwW5nNIo4kxQJQ6W6p3squ/b/oNOqx6TLD9NfuyhX68p+GRvlZeR4mJej7RlbbFbFrCrmP8t1dQoIa3m5zUv71zOXkY55GL4JkAFSQAKIASPAEBABHAOBQWAQGAQGgUFgEBgEBoFBUlQQFYI6pvTc0OSoxlJUxnMqpRgGZ6wqSUmklElCUo9ogQmcRG6rG7uQOFVPTIwVRaJvdd57hpZH+9bdbXWamqdcDcjAUCjzzZYVhM/HfLrFFn61rd521w9oytoslfXG... |
705,614 | Binary Tree K level sum | Given a binary tree s and a number k, the task is to find the sum of tree nodes at level k. The Binary Tree is given in string form s: (node-value(left-subtree)(right-subtree)).
Examples:
Input:
s =
"
(0(5(6()())(4()(9()())))(7(1()())(3()())))" , k = 2
Output:
14
Explanation:
The Tree from the above String will be fo... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int kLevelSum(String s, 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 = new BufferedReade... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"kLevelSum(self,s,k)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n s = input()\n k = int(input())\n ob = Solution()\n ... | eJy9VLFOwzAQZWDgM6JMF6lCPjuOHSY2fgEJIwbIwOJ2SCUkBOIj4H85O3ZTIV1IU2ikOPar796786s/zr9uLs7ic3tNk7vX8tlvtn15VZToPCBIUFCDhgYMWGgBBVRQjY/zrfPlqii7l0332HdPD+ttnzMI59/p17dV8TOvCGkkjSrOahp1nDU0GnptXLVh3OPSLBfFcWRaEFMQrqN0wOFbETfIhKmEVUROGkAnvMl7LclKmM17SZBiBamGr14PalSoPOenDsfsbRaCChCT4jqDoRALaBKeNocypBowaUd1km8XcuJUVBB4Urkmc9vY... |
702,712 | Find Kth Rotation | Given an increasing sorted rotated array arr of distinct integers. The array is right-rotatedktimes. Find the value ofk.Let's suppose we have an array arr = [2, 4, 6, 9], so if we rotate it by 2 times so that it will look like this:After 1st Rotation : [9, 2, 4, 6]After 2nd Rotation : [6, 9, 2, 4]
Examples:
Input:
arr ... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int findKRotation(List<Integer> arr)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n // Driver code\n public static void main(String[] args) throws Exce... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"findKRotation(self, arr)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input().strip())\n for _ in range(t):\n arr = list(map(int, input().strip().split()))\n ... | eJzNVcFKw0AQ9eDFvxhyLpKd3dkkXr35BYIVD5qDl9hDCoIofoT+r5OZMbQ2m7Y01AbaVwr7+t7bedPP8++bizN5bq/5w91b9twslm12BZmbNy6XBxSdIRp6w2BIhtGwMCwNK0andE7ZXEdWdU+u4BTsS68QFEghKhQKpUKVzSCrXxf1Y1s/Pbws218P+bz5mDfZ+wzWnekpVgQIHgIQRCiA2VgVONbGJtkfW2NXbIi9sI0KMAfkMwjoAQMgAUbAArAErMCbjapM6UnIIYmZJGSSiEkCJomXJFySaEmCJYmVJFR+d3K2kz1kJ4wFhAlF... |
712,223 | Combination Sum II | Given an array of integers arr, the length of the array n, and an integer k, find all the unique combinations in arr where the sum of the combination is equal to k. Each number can only be used once in a combination.Return the combinations in the lexicographically sorted order, where each combination is in non-decreasi... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1675572590,
"func_sign": [
"public List<List<Integer>> CombinationSum2(int arr[], int n, int k)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\npublic class Main {\n\n public static v... | {
"class_name": "Solution",
"created_at_timestamp": 1692193868,
"func_sign": [
"CombinationSum2(self, arr, n, k)"
],
"initial_code": "# Initial Template for Python 3\n\nfor _ in range(int(input())):\n n, k = map(int, input().split())\n arr = list(map(int, input().split()))\n\n ob = Solution()\n ... | eJydVE1LxEAM9aD/4zHnIsl8gf4SoV08aA9exj10QVgU8Tfo/zWTdpeykO52y0xImEleXvPa79u/n7sbfZ724rR791a2u8E9wnFXGNW4Bq7/2PYvQ//6/L4bpvOWN1356or7bHCaRgtpVpZXMPjVcB6hGiuxK0ZeQFSKsFo1MyOyIsJGbX2Duqymk74jKSBdIK19Vwmc1BJGYxVIDeqSOtVlsgpmPMzaQTaHoKxyrSdumEp7dWN1w3QaxyMDjKmyJ3hCIEQhQMhkgpKgyg6yIyn2FOVjFGUnjQ43xygebp2bAgvvoyjWi5evUq+gGwnL... |
714,262 | String Mirror | You are given a string strof length n. You want to choose a non-zero integer k (k<=n), such that you can perform the following operation:
Take the prefix of the string of length k and append the reverse of it to itself.
Your task is to find the lexicographically smallest string you can get.
Examples:
Input:
str = "bvdf... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1678885472,
"func_sign": [
"public static String stringMirror(String str)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n BufferedReader br = new Buffere... | {
"class_name": "Solution",
"created_at_timestamp": 1678885472,
"func_sign": [
"stringMirror(self, str : str) -> str"
],
"initial_code": "if __name__ == \"__main__\":\n t = int(input())\n for _ in range(t):\n str = input()\n obj = Solution()\n res = obj.stringMirror(str)\n ... | eJydk00KwjAQhV30ICXrImTrSQQjkr+Fm1gkBY0oHkLv62RoKyivkMyqMHzz3rxMn8372qy4tmf62N3EMfRDFJtWSBW06FrhL7230bvDaYhjS2sVHiqIe9f+AMY6Xwp5Zw1S4h5PRYpUplTRZApA3OOpAE4ATAlZRAT0l5C5pDVUwSthnVyl64xaSExKzHEYhE4jTPkUpZBhlWvhSGrueTaKz3rB6ZQwdkww8vzNiMRlsTqHTGFV/B3ZdsW+/57xW81D9q/1B0iKftE= |
703,836 | Max Sum Subarray of size K | Given an array of integers Arr of size N and a number K. Returnthe maximum sum of a subarray of size K.
Examples:
Input:
N = 4, K = 2
Arr = [100, 200, 300, 400]
Output:
700
Explanation:
Arr
3
+ Arr
4 =700,
which is maximum.
Input:
N = 4, K = 4
Arr = [100, 200, 300, 400]
Output:
1000
Explanation:
Arr
1
+ Arr
2
+ A... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1729857990,
"func_sign": [
"public long maximumSumSubarray(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... | {
"class_name": "Solution",
"created_at_timestamp": 1729857990,
"func_sign": [
"maximumSumSubarray(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 = in... | eJzdVstuFEEM5MCVf7DmHKF2P6f5EiQWcYA9cFly2EhICMRHwJEbH0rZtVkGlB6WkAdKr7ocpV22x2175vPjr9+fPPL1/Bv+ePFhers7v9hPz2RKm52GIBE7YWfsgl2xG/aM3bGhAzBNNVU1XTVlhfZmV8wKjMAGTMACDIAPOtii5BrVmEY0niiUFFoKNe0ehNmBORxLLJKK5CKlSC3SisxFOo4CNs4VCgoNzaaODSWFlkJNOyJK05lM2/fn29f77ZtX7y72h0euHvInuCqFf0wfz2SRk4gjiZIkC1xLk1m6WFxMlqWi23KcHZtjdSyO... |
703,907 | Maximum weight difference | Given an array arr[].The task is to choose k numbers from the array such that the absolute difference between the sum of chosen numbers and the sum of remaining numbers is maximum.
Examples:
Input:
arr[] = [8, 4, 5, 2, 10] , k=2
Output:
17
Explanation:
If we select 2 and 4, then abs((2+4) - (8+5+10)) = 17.
Input:
ar... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1617816639,
"func_sign": [
"public long MaxWeightDiff(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": 1617816639,
"func_sign": [
"MaxWeightDiff(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(in... | eJzNVctOw0AM5MCJn8DKgVOF6t3NrsOXIBHEAXrgEji0EhIC8RHwv4zdSi1Qh/TBw5bsSIm9k9nZ9cvh28nRgdn5MR4uHqvb7n42rc6o4rbjsRo1ahaFAkViSlTbm9B2qRpRNXm4n1xPJzdXd7PpojwmfB/b7rntqqcRfWpsfdCFMhUSaojHxEwciNE/EdfEmbgQC3FDYaxgnJWA0llmFbjGYjFbrC0mi9FisMgW7afFasVqxWrFasVqxWrFasVqxWoFaGoHqoHw0C7Y/g+ph20PfW212DioQpWBHJEjckJOyNAM1cgZOSMX5IIsyILc... |
702,730 | Sum of Array | You are given an integer array arr[]. The task is to find the sum of it.
Examples:
Input:
arr[] = [1, 2, 3, 4]
Output:
10
Explanation:
1 + 2 + 3 + 4 = 10.
Input:
arr[] = [1, 3, 3]
Output:
7
Explanation:
1 + 3 + 3 = 7.
Constraints:
1 <= arr.size <= 10**5
1 <= arr[i] <= 10**4 | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int sum(int arr[])"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"_sum(self,arr)"
],
"initial_code": "# Driver code\nif __name__ == \"__main__\":\n tc = int(input())\n while tc > 0:\n arr = list(map(int, input().strip().split()))\n ob = Solution()\n ans = ob._sum(a... | eJztmMFuE0EMhjnwIL/CkQrteMb2mCdBoogD9MAl9NBKSAjEQ8D74n8leiidNK1aNqQ7da1Kyb/Neuz/28yP57/kxbN5vXmZf7z9uvm0Pb+82LzGppxuy5QLa17zg+bNCTZnX87PPlycfXz/+fLiT8NN8zrdfj/dbr6d4Fov4ih+xvc+um+pDWreEWXKCxQpqKUVaLECL70gZBIUEUGVJlAxgUsXRJ0qSpWKWluFVqvw2iuiTQ2lSUNtLS/frMFbbwidFEVFUbUpVE3h2hVhk6GYGKo1yw9kBrduCJ8cxcVRvTnUzeHeHdGnjtKlo/bW... |
712,111 | Search in Rotated Array 2 | Given a sorted and rotated array arr and a target key k which is rotated at some point, and may contain duplicates and given an element key. Check whether the key is present in the array or not.
Examples:
Input:
arr[] = [2, 5, 6, 0, 0, 1, 2], k = 0
Output:
true
Explanation:
0 is found at index 3.
Input:
arr[] = [2, 5... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1663847756,
"func_sign": [
"public static boolean Search(int[] arr, int k)"
],
"initial_code": "// Initial Template for Java\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass GFG... | {
"class_name": "Solution",
"created_at_timestamp": 1675176561,
"func_sign": [
"Search(self, arr, key)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == \"__main__\":\n t = int(input())\n while t > 0:\n k = int(input())\n arr = list(map(int, input().split()))\n ... | eJytVN0KwiAU7qLe4+D1CN2QsZ4kyIgogyAsykERxR6i3rezn5gW0nR5vDgg34/fdiyGz2I0qNb0gs3sSrbqkGsyAcKEorhJBESeD3Kl5Xqxz3Vzqo+5FOouFLlFYKM4bn8UQzEOZrEA7aQkYZAE6AsVg13MnyVGC2CVg2Oz3J1cJBm6QSiHFLKQIJtltBiJUUHhGFxdu37eA4JL3H/er7wDYG+zaZ00fEXtTMCPtbwYc0wIVdwW5X9R9WWg/b+dyeAtT6uUyofHG/vhvB1hIdoh9r5Qzdf5MZw/xi9Ae6XV |
713,142 | Absolute difference divisible by K | Given an array of integersof size n and an integerk, find all the pairs in the arraywhose absolute difference is divisible by k.Example 1:
Examples:
Input:
n = 3
arr[] = {3, 7, 11}
k = 4
Output:
3
Explanation:
(11-3) = 8 is divisible by 4
(11-7) = 4 is divisible by 4
(7-3) = 4 is divisible by 4
Input:
n = 4
arr[] = ... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1671445136,
"func_sign": [
"static long countPairs(int n, int[] arr, int k)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n\tpublic static void main(String args[]) throws IOException {\n\t\tBuff... | {
"class_name": "Solution",
"created_at_timestamp": 1671445136,
"func_sign": [
"countPairs(self, n, arr, k)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n n = int(input())\n arr = list(map(int, input().split(... | eJy1VMtOhTAQdWH8jpOub8xMaUvxS0zEuFAWbvAuIDHxET9C/9eZcsnNNRaBYAsHEtozp2eG+Tj/er04S+O6l5ebF/PY7vvOXMFw3dq6ZciTzQ6med43913zcPfUd8cl73Vr3nY43eflwmFO7KbM9qDbmcAelmA9Clnpcyw+w6L0TISKEAklIRA8wZHQKe/wPcPqcqyDJaSjbisdC70ZZVlSIapHZak6FalaVTKlGGnlUoUpACwKOPE/oERENZw2l4lcIjR5osSCHTiAo5x/aTJ59AkKMWGZMCT0CV3CIqFNyAkpXz5ZA+JwflEtHuic... |
700,243 | Run Length Encoding | Given a string s, Your task is to complete the function encode that returns the run length encodedstring for the givenstring.egif the input string is “wwwwaaadexxxxxx”, then the function should return “w4a3d1e1x6″.You are required to complete the function encode that takes only one argument the string which is to be en... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1708940422,
"func_sign": [
"public static String encode(String s)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(... | {
"class_name": "Solution",
"created_at_timestamp": 1617138615,
"func_sign": [
"encode(self, s : str) -> str"
],
"initial_code": "if __name__ == \"__main__\":\n t = int(input())\n for _ in range(t):\n s = (input())\n obj = Solution()\n res = obj.encode(s)\n print(res)\n\n... | eJy1VsuO00AQ5MCFv4h8XiF1e8wivgSJIOR5ePx+ZfxEID4C/oYbP8b0bjYBbcZxomydEsnqqaqu7pkfr3/9efPqAR9/2x+fvnpJWXfG+7DxYFsOFmEYSjU+wLvbeGqslTBKfqk6s/9wYKEvQcH4blt+35bet7vN/2Vqi2aPtt0RjDGdRW8xOMrWrHnf4i4wfsd6NoCjeMiFVJGOkzTLi7Kqm3Znun4Yp9lRNwQOAohwBBpiSCCFDHIooIQKamighR0Y6KCHAUaYYHaeHXIuhJRKRZHWcZwkaZpleV4UZVlVJJrkklQrcxjHaZqdrJCj... |
706,234 | Even and Odd | Given an array arr[] of size N containing equal number of odd and even numbers. Arrange the numbers in such a way that all the even numbers get the even index and odd numbers get the odd index.Note: There are multiple possible solutions, Print any one of them. Also, 0-based indexing is considered.
Examples:
Input:
N = ... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1616193367,
"func_sign": [
"static void reArrange(int[] arr, int N)"
],
"initial_code": "import java.io.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String args[]) throws IOException {\n BufferedReader read =\n new Buffere... | {
"class_name": "Solution",
"created_at_timestamp": 1616193367,
"func_sign": [
"reArrange(self, arr, N)"
],
"initial_code": "# Initial Template for Python 3\ndef check(arr, n):\n flag = 1\n c = d = 0\n for i in range(n):\n if i % 2 == 0:\n if arr[i] % 2:\n flag = ... | eJy1lEFLw0AUhD2Iv2PIucjue9kk6y8RrHjQHLzEHlooiOKP0P/qTedtC7YlTcgSS1tKk53Zb+ZlPy6/fq4u0uv2mz/uXovnbrVZFzco/LLzbtlFNKhRIaCEQuBh/xYLFO121T6u26eHl836b807L74tcCzUUCutLvdazWQJoat4iEAoVEICpILUkAYSoQ5KC4EqlDsN0ApaQxtoRDl9y174IazCB/gaPsLsSVAxEe9gN0xlsBimL7PAD42ZZGCOMStDCvRUyrck1jLhVom4SdDTo9vbqGkGk6xNMSZB8jszYo80Yo80Yo9mxB59nhcZ... |
703,061 | Count Substrings | Given a binary string S. The task is to count the number of substrings that starts and end with 1.Note: The starting and the ending 1s should be different.
Examples:
Input:
S = "10101"
Output:
3
Explanation:
The 3 substrings are "101",
"10101" and "101".
Input:
S = "100"
Output:
0
Explanation:
No substring that sta... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int countSubstr(String S)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\nclass GfG\n{\n public static void main (String[] args)\n {\n \n Scanner sc = new Scanner... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"countSubstr(self, S)"
],
"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.countSubs... | eJy1lMEKgkAQhjvUU3SROUvsrBnRkwQVHcpDF/OgIETQQ9T7tjsmCv6z6KFdZReZ+fn9ZnZf8w8tZjL2S7c5POiWF1VJu4iSY87MxrjFuOn37D+Z30NxRFldZJcyu57vVdmlWW5eesZRT9BKthsi44cuwekgfe2NtMmNlKxGpiLlApzaRh5gp7PifekawE7Ssui5aIgJLE0rFUOAjhdRkgwK1tzCYN0Pjg6Wx25hUqgGqBN4QjskGP90/pY1/mo9xxV0yEQr0BBduLN1sLDUE7roPwzBlTHmwgBHrDuhoaOJIISJovYL/K+AO71XX373... |
702,740 | Max Length Removal | You are given a binary string S consisting of only characters '0' and '1'. You can repeatedly delete any occurrence of the sub-string "100" from S. Your task is to determine the length of the longest continuous sub-string that can be completely removed by applying this deletion operation.
Examples:
Input:
s = "10111000... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615835030,
"func_sign": [
"public static int longestNull(String s)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass GFG {\n public static void main(String[] args) throws IOExcep... | {
"class_name": "Solution",
"created_at_timestamp": 1615835030,
"func_sign": [
"longestNull(self,s)"
],
"initial_code": "# Initial Template for Python 3\n\ndef main():\n T = int(input())\n while T > 0:\n s = input()\n ob = Solution()\n print(ob.longestNull(s))\n T -= 1\n ... | eJxrYJnqy8IABhFuQEZ0tVJmXkFpiZKVgpJhTJ6Bko6CUmpFQWpySWpKfH5pCVTKICavLiZPqVZHAVW9IanqDXDZYIxDhwFOHTjtMCTZVaQ7C6gDtyYz3C4zwKcPp2VwQKLHDOCAbI2E/EqCCWSaQbbFZLud5GwAtYn0pApzLlgzifGLxz5sXqIgHAlpjZ2iBwBRP1Ad |
704,714 | Killing Spree | There are Infinite People Standing in a row, indexed from 1.
A person having index 'i' hasstrength of (i*i).
You have Strength 'P'. You need to tell what is the maximum number of People You can Kill With your Strength P.
You can only Kill a person with strength 'X' if P >= 'X' and after killing him, Your Strength decre... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"long killinSpree(long n)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])throws IOException\n {\n \n Buffer... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"killinSpree(self, n)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n ob = Solution()\n t = int(input())\n for _ in range(t):\n N = int(input())\n ans = ob.killinSpree... | eJytlD0OwjAMhRngHlXmCjk/dVJOgkSBATKwBIZWQkIgDgH3JaqIlFa4LRRPGfI5fs927tOnnU3qWG78YXVhB3eqSrZIGC8chyhYmjB7PtldaffbY1WGa0oJf/VWOHZNkyafR/EDng143fNI4FxIlaE2OXBB4JoboGo3GjMlBYfckLVLFARuoqBwaZCqXUdB4gIlJb3fOcScovu71gFHrhOwlJJyDd6F13konFMtMwNMF76vWZdrrbGF9hrQfn6T1Y1OG2X7w6ZS0mFkkWGJmhPdvVOd7QnTATCkMC/5o+Ja2sjvxQwZN/RfRNCzfsxf... |
703,171 | Divisible by 8 | Given a number S,you need to check whether any permutation of the number Sdivisible by 8 or not.
Examples:
Input:
S = "80"
Output:
"Divisible"
Explanation:
80 is divisible by 8
Input:
S = "101"
Output:
"Not divisible"
| geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"int isDivisible8(String S)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])throws IOException\n {\n BufferedReader... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"isDivisible8(self, S)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n s = input().strip()\n ob = Solution()\n if (ob.isDiv... | eJxrYJnKzcoABhEsQEZ0tVJmXkFpiZKVgpJhTJ6FuaWZko6CUmpFQWpySWpKfH5pCVTWJbMsszgzKSc1Jq8uJk+pVkcBVauhkbGJqZm5hSWZ+o1MzCzItdrY1NwSpN+ATAPI1Ue2g8kNZCNjHBr98ksUCLqWbOdSZC3IZjyRS4wRRuAwo8QRYBMo8oURRYEAtp9C/VQIApAR+PMacWEBLSooTI5UClakNGZMRlDHTtEDAAtVpwA= |
701,168 | Modular Multiplicative Inverse | Given two integers ‘a’ and ‘m’. The task is to find the smallest modular multiplicative inverse of ‘a’ under modulo ‘m’. if it does not exist then return -1.
Examples:
Input:
a = 3
m = 11
Output:
4
Explanation:
Since (4*3) mod 11 = 1, 4
is modulo inverse of 3. One might think,
15 also as a valid output as "(15*3)
m... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int modInverse(int a, int m)"
],
"initial_code": "//Initial Template for Java\n\n/*package whatever //do not write package name here */\n\nimport java.io.*;\nimport java.util.*;\nclass Main {\n\tpublic static void main ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"modInverse(self,a,m)"
],
"initial_code": "# Initial Template for Python 3\nimport math\n# Position this line where user code will be pasted.\n\n\ndef main():\n T = int(input())\n while T > 0:\n am = [int(x) for x ... | eJylVLtOBDEMpID/sFJQ3aHYifPgS5A4RAFb0CxX7ElI6E58BPwvXlid2GLCLbiKlIztGXvydv6xvjj7iptLO9y+uqd+uxvcNTne9LXWTOy9t7Nbketett3D0D3eP++G6ZWo95v+YPf7Fc3RLCGSpagQrJIVgDXlQrXkBMFrBtAQNVEu1S+HWj2lGATzLb4ArMRUiINmzJdFBKrl2aQOWCvUs4lESSNGQrZsQdaSLIdmCyoWfx7PXG1MO8R2nlGX/zUklui3yUHwcU+XV52KQipsXBq7xIHhSoy+DZNx5wwbCUuuowItL+NvALnix4xP... |
701,722 | Sort an array according to the other | Given two integer arrays A1[ ] and A2[ ] of size N and M respectively. Sort the first array A1[ ]such that all the relative positions of the elements in the first array are the same as the elements in the second array A2[ ].See example for better understanding.Note: If elements are repeated in the second array, conside... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1616489310,
"func_sign": [
"public static int[] sortA1ByA2(int A1[], int N, int A2[], int M)"
],
"initial_code": "//Initial Template for Java\n\n/*package whatever //do not write package name here */\n\nimport java.util.*;\nimport java.lang.*;\nimport ja... | {
"class_name": "Solution",
"created_at_timestamp": 1616489310,
"func_sign": [
"relativeSort(self,A1, N, A2, M)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n while t > 0:\n n, m = list(map(int, input().split()))\n a1 = list(map(... | eJzVV0uO00AQZcEBOEIpGzajkfvnDydBIogFZMHGzCIjISEQh4D78uq5nfGvPAnJZDRlKY6T7nqvvl3+/frv7ZtXlPdv8eXDj83X9u5+v3knG7dtXSFp2wbpLo/L4Yrdj16SPmzbzY1sdt/vdp/3uy+fvt3v8/7htpQ3bttfWP/zRiY4SUpFo0hDkZoiFUVKiiSKRIoEiniKOIqANDZLpSr11qvNe3SByXlpfSElFGblGSoDZzaZW2aaeWcrLIu9VPyE6Q4gYBXEleKAX4trxBfiFW7bAk6/Ffqr/ocVpWnA0mJq9wSIimdQqiWAEQOl... |
703,114 | Factorials of large numbers | Given an integer N, find its factorial.return a list of integers denoting the digits that make up the factorial of N.Example 1:
Examples:
Input:
N = 5
Output:
[1,2,0]
Explanation
: 5! = 1*2*3*4*5 = 120
Input:
N = 10
Output:
[3,6,2,8,8,0,0]
Explanation
:
10! = 1*2*3*4*5*6*7*8*9*10 = 3628800
Constraints
:
1 ≤ N ≤ ... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1730504080,
"func_sign": [
"public static ArrayList<Integer> factorial(int n)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\n//Position this line where user code will be pasted.\n\nclass GfG {\n public s... | {
"class_name": "Solution",
"created_at_timestamp": 1730504080,
"func_sign": [
"factorial(self, n)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n ob = Solution()\n ans = ob.factorial... | eJztnU2ubUmSlWkwEFO0S8j/fxgJEoFoQDboBNXIkpAQiEHABOkxBjq8u9f63E+k6gWZVFZmELXzKOO9d8+5+/h2t59lZsts/7d//j/+1//+Z8///tX//PaXf/2ff/gPP/3t3/3+h38ZP5Qff8opPf/59t8f/iZ++N1/+tvf/bvf/+7f/9v/+He/94d21G+vEuPb/3P0aN9eNfbz59e/v95Z3/42vv1sf/tX/fav9e3n43lnxIz07dW+vZe+/f3rN/bzG1/vtufT2dduz8/7c5Wvz3y9t59vyN9+sz/X/3p9raY8f8vP96Tnc81X+Frb... |
705,707 | Count the paths | Given a Directed acyclic graph(DAG) with n nodes labelled from 0 to n-1. Given edges, start, and destination, count the number of ways to reach from start to destination. There is a directed Edge from vertex edges[i][0] to the vertex edges[i][1]. Your task is to find the number of ways to reach from start to destinatio... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int possible_paths(int[][] edges, int n, int start, int destination)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass GFG {\n public static voi... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"possible_paths(self, edges, n, start, destination)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n, m, s, d = input().split()\n ... | eJzFVbtOAzEQvIIC/mLlOkK2z0++BAkjCkhBY1IkEhIK4iPgY+nwrk1yBPmILwFS2MrK3p2ZnT2/nLx1Zx39Lt9Pu+7qid3HxWrJLoCJEIUGyYGDUCGmFReZotDjkmISNC4mxB5siApciBp8iAYED9GCSHcciHTJg8BbOZcQeZN562nrMY/cHJNsBmz+uJjfLud3Nw+rZYGVSjyHyNYz2MGKd4Cqa8xkEJFFRC7H6C9ho5jeQPWIjmKmsWaihvLYoo5AdSSq06M6Ktf4xLLVLolVKWRGyOlUyQ/7wL/2gfRTWEkjG+JFhF1m6PGcxXMO... |
703,872 | Repeated IDs | Geek is given a task to select at most 10 employees for a company project. Each employee is represented by a single-digit ID number which is unique for all the selected employees for the project. Geek has a technical problem in his system which printed ID number multiple times. You are given array arrhaving all printed... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public ArrayList<Integer> uniqueId(int[] arr)"
],
"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass Main {\n public static void main(String args[]) throws ... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"uniqueId(self, arr)"
],
"initial_code": "# Initial Template for Python 3\n# Position this line where user code will be pasted.\n\nif __name__ == \"__main__\":\n t = int(input())\n\n while t > 0:\n arr = list(map(i... | eJytU8sOgjAQ9GD8jknPxPAqgl9iIsaDcvCCHCAhMT5OfoH+r6sxRmSX0ApzIdvp7LYzvYzv18no9S3O9LM8qF1eVKWaQ3lp7oJBmisHKquLbFNm2/W+Kt8baOVEi0cHTZUEDESVRFDx4CNACI0IM8SkIU/CcoXZYmJExAxphw+vQ5Xlsqoa1hC7a6GXC+a07ZrsGscVOjE30K51dGK4/RPTDxa5soacPwOvTBLY3yttkiJXIP/SxLkYB01dMLzJtvP6WezyHyYvaBgXjPMkjvLFIlrwR+4GPmKT+ZG20l7dpg9yc6/8 |
702,054 | Search an element in sorted and rotated array | Given a sorted and rotated array A of N distinct elements which are rotated at some point, and given an element K. The task is to find the index of the given element K in array A.
Examples:
Input:
N = 9
A[] = {5,6,7,8,9,10,1,2,3}
K = 10
Output:
5
Explanation:
10 is found at index 5.
Input:
N = 3
A[] = {3,1,2}
K = 1
... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1617909219,
"func_sign": [
"static int Search(int array[], int target)"
],
"initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*; \n\nclass GFG{\n public static void main(String args[]) throws IOException { \n Scan... | {
"class_name": null,
"created_at_timestamp": 1617909219,
"func_sign": [
"Search(arr,n,k)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n tcs = int(input())\n for _ in range(tcs):\n n = int(input())\n arr = [int(x) for x in input().split()]\n ... | eJztlt2KFDEQhb3wzpf4mOtVuiqppOKTCLZ4oXMhQrvILAii+BD6vlbPjDrump2dH1kQhww03V0n55ycVPrLw2/vHz1Y/569jYvnHxdvpsur1eIpCxknHcZJDClIRRxp6ICgJDJGoeI0JG4KokhC8jjFWFywWH64XL5aLV+/fHe12oK2cfocDz9d8PtMFjOlgSSkAE+kTDJSIVWSkxp5IAtZyTF3Jhu5kCvZyQ3bT4ubSjRqFE1oRg0taEUdbRtGHRGzLX9UIUM8McEUS1hwMaxgFXOsUQaKUJSSKJkSVAulUpzSqANVqEpN1Ew1aiip... |
706,217 | 3 sum closest | Given an array A[]ofNintegers and an integerX.The task is to find the sum of three integers in A[]such that it is closest toX.
Examples:
Input:
N = 4
A[] = {-1 , 2, 1, -4}
X = 1
Output:
2
Explanation:
Sums of triplets:
(-1) + 2 + 1 = 2
(-1) + 2 + (-4) = -3
2 + 1 + (-4) = -1
2 is closest to 1.
Input:
N = 5
A[] = {1, 2... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1618854875,
"func_sign": [
"static int closest3Sum(int A[], int N, int 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 {\n ... | {
"class_name": "Solution",
"created_at_timestamp": 1618854875,
"func_sign": [
"closest3Sum(self, A, N, X)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n Arr = input().split()\n for ... | eJylVMFOwzAM5YD4DqvnBaVp0zZ8BTeQCOIAPXAJO3QSEgLxEfC/+KVZKahu121TrC2xn+3nl3yef99cnMXP7TX/uHvLnsN212VXlOU+5BpLa1LROudIwVhswWjK+YyMD4Ydsg1l7eu2fezap4eXXZeAcOTDhw/Z+4b+Jmh8YGhSRlOhqdSMTJWmmrcajrESpJUAKy6Yhq8PhQBQCPE5txI7UyVMoWNxPQHoli3+Yh8O8Kx0YklIlcvt11xgQuzxY5o+YYEoCVMCtOCMS+MZla7hVfMCJ1Yuj50ENJemPxp3LwRleE5YubG8ZWx0lBLg... |
704,209 | N-divisors | Given three integers A, B, N. Your task is to print the number of numbers between A and B including them,which have N-divisors. A number is called N-divisor if it has total N divisors including 1 and itself.
Examples:
Input:
A = 1
B = 7
N = 2
Output:
4
Explanation:
2,3,5,7 have 2-divisors
Input:
A = 1
B = 25
N = 3
... | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int count(int A,int B,int N)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])throws IOException\n {\n Buffe... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"count(self,A,B,N)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n A, B, N = input().split()\n A = int(A)\n B = int(B)\n ... | eJxrYJm6j4UBDCK2AxnR1UqZeQWlJUpWCkqGMXmGCkAYk6eko6CUWlGQmlySmhKfX1qCUFAHlKzVUcDUZYRTlwFuXQZ4LMOrzYR0bUC7DIDYjCwLgYBMH4J0GpOs09LS0gCqmXSvmoK0mYEIU9ItBmmDWExRSBnGxJAfWJQlDnRDDAwMwTxgsFAWHqS7RQFiMynZyQCHYnRlBkQqRHJIXkwMeuogI6cTCF8yQon0aI+dogcAKcFuPw== |
705,088 | Party in Town | Geek town has N Houses numbered from 1 to N. They are connected with each other via N-1 bidirectional roads. Givenan adjacency list adjto represent the connections. To host the optimal party, you need to identifythe house from which the distance to the farthest house isminimum. Find thisdistance.
Examples:
Input:
N = 4... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"static int partyHouse(int N, ArrayList<ArrayList<Integer>> adj)"
],
"initial_code": "//Initial Template for Java\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG{\n public static void main(String args[])throws IOExcep... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"partyHouse(self, N, adj)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n adj = [[] for x in range(N+1)]\n ... | eJytlD1Ow0AQhV0A53jaOkKe/bU5CRKLKMAFzZLCkSIhEIeAw9KxsxgSIGNYCxdp7Pf589uZPB29NCdNuc5fj5vm4l7dpvVmVGdQFJOOiaDVCmrYrofrcbi5utuMu/uPMamHFb6GXAnlMExMBjYmCycwtMDw+ww9MTIavhLUTSD6lDETiH9CTAGdgDQCktpDHzgx/cTMb0YfUw9qBbyT8MLzrfC82X1h5UHZ/W4ItjKu2295bsRxI54bCdxIx4303Ai31oGodMKhFsQxArGHBvHcGBAfvQXlODkQn58HZQQFaKnLIHXpDitqVjSsaFjR... |
703,715 | Addition of Two Numbers | Given two numbers Aand B. Your task is to return the sum of A and B.
Examples:
Input:
A = 1, B = 2
Output:
3
Explanation:
Addition of 1 and 2 is 3.
Input:
A = 10, B = 20
Output:
30
Explanation:
Addition os 10 and 20 is 30.
Constraints:
1 <= A, B<= 10**18 | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1618328593,
"func_sign": [
"static int addition(int A, int B)"
],
"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 BufferedR... | {
"class_name": "Solution",
"created_at_timestamp": 1618328593,
"func_sign": [
"addition(ob,A,B)"
],
"initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n A, B = map(int, input().strip().split(\" \"))\n ob = Solution()\n ... | eJxrYJn6jYkBDCLeAxnR1UqZeQWlJUpWCkqGMXmGCoZKOgpKqRUFqcklqSnx+aUlUEmjmLy6mDylWh0FNB0GCkYGOPQYG+DSpGCESwsOHQYKuCzBaQdQCy7PGBpi04TLBmzuh/mc1OAyAOk0ALrZ0NAAT8hhdR8kGEgNB4iNCmArwSFPlsWGBoZ4gtMAp3eJthir82F68fscXRNudbFT9ADlFejY |
703,905 | Sum Of Digits | Given a number,N. Find the sum of all the digits of N
Examples:
Input:
N = 12
Output:
3
Explanation:
Sum of 12's digits:
1 + 2 = 3
Input:
N = 23
Output:
5
Explanation:
Sum of 23's digits:
2 + 3 = 5
Constraints:
1<=N<=10**5 | geeksforgeeks | Easy | {
"class_name": "Solution",
"created_at_timestamp": 1619087265,
"func_sign": [
"static int sumOfDigits(int N)"
],
"initial_code": "//Initial Template for Java\nimport java.io.*;\nimport java.util.*;\n\nclass GFG\n{\n public static void main(String args[])throws IOException\n {\n BufferedReade... | {
"class_name": "Solution",
"created_at_timestamp": 1619087265,
"func_sign": [
"sumOfDigits(self, N)"
],
"initial_code": "# Initial Template for Python 3\nif __name__ == '__main__':\n t = int(input())\n for _ in range(t):\n N = int(input())\n\n ob = Solution()\n print(ob.sumOfDi... | eJytk80KgkAUhVv4IDJriZk7Pzo9SZDRoly0mVwoBFH0EPUq7Xq3ZkqFhDMSdDcKes49fnO8JvdnMnvP8uFvVie2d3XbsEXKROlskRvNspRVx7raNtVuc2ib7rHUpbuUjp2z9FskwgAR0mglCWkEXMQ5RyICGhsGaBRcRFIhDDCdyQvLETuOOIRBn4Q5CMhBAg0pU6B0FE03AZEM4tEbQCp5rBz+OlhAB4GWjy2cnkwDvULtfu7dB9w/Y/h+9dWEYkJxxPg0Iw3HHpEfHR5Ex6Hfi3nY8ErsJxrIrG/zFwCbcok= |
705,719 | Negative weight cycle | Given a weighted directed graph with n nodes and m edges. Nodes are labeled from 0 to n-1, the task is to check if it contains a negative weight cycle or not.Note:edges[i] isdefined as u, v and weight.
Examples:
Input:
n = 3, edges = {{0,1,-1},{1,2,-2},
{2,0,-3}}
Output:
1
Explanation:
The graph contains negative we... | geeksforgeeks | Medium | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"public int isNegativeWeightCycle(int n, int[][] edges)"
],
"initial_code": "//Initial Template for Java\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass GFG\n{\n public static void main(String[] args) t... | {
"class_name": "Solution",
"created_at_timestamp": 1615292571,
"func_sign": [
"isNegativeWeightCycle(self, n, edges)"
],
"initial_code": "# Initial Template for Python 3\n\nif __name__ == '__main__':\n T = int(input())\n for i in range(T):\n n, m = input().split()\n n = int(n)\n ... | eJydlM0OATEQxx08yKRnK+20FfEkEisO7MGlHFYiEeIheEI3T2FmB4nSpfawbXbn/5vP9tg9X7ud5hlfaDPZqWVYb2o1AmXKgEAvDQYKXwbVA1Vt19W8rhaz1aa+m+kyHOjnvgevWg9etLQ30JAQLC8WHC8OdBvXJLgOXJJLQMwOFAEFaBlICJcdk5E6kdZkawcwEPco+aDkg1In5IQ9L77B22y+5byY74Tvmc8o/UfpfTJULVVEKIZ/hIhxSzN7SP7zNC2N+mFCHt8gGpv05HwOolUSGROhMOz4N/OWg/BWinTt3kzT8xebpscgTiyj... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.