{"payload":{"feedbackUrl":"https://github.com/orgs/community/discussions/53140","repo":{"id":750429969,"defaultBranch":"main","name":"GeeksforGeeks-POTD-solutions","ownerLogin":"dhr7va","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2024-01-30T16:23:45.000Z","ownerAvatar":"https://github.com/avatars/u/138505718?v=4","public":true,"private":false,"isOrgOwned":false},"refInfo":{"name":"","listCacheKey":"v0:1706631947.0","currentOid":""},"activityList":{"items":[{"before":"e296fe86dd9443aa289ff2294fa25f5b06a77ba0","after":"d879438723f48f3c1cb2b5233f9e774f90cfafda","ref":"refs/heads/main","pushedAt":"2024-09-15T07:30:36.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 15-09-2024.py\n\nBinary Tree to DLL\r\nDifficulty: HardAccuracy: 53.36%Submissions: 142K+Points: 8\r\n\r\nGiven a Binary Tree (BT), convert it to a Doubly Linked List (DLL) in place. The left and right pointers in nodes will be used as previous and next pointers respectively in converted DLL. The order of nodes in DLL must be the same as the order of the given Binary Tree. The first node of Inorder traversal (leftmost node in BT) must be the head node of the DLL.\r\n\r\nNote: h is the tree's height, and this space is used implicitly for the recursion stack.\r\n\r\nTreeToList\r\n\r\nExamples:\r\n\r\nInput:\r\n 1\r\n / \\\r\n 3 2\r\nOutput:\r\n3 1 2 \r\n2 1 3\r\n\r\nExplanation: DLL would be 3<=>1<=>2\r\n\r\nInput:\r\n 10\r\n / \\\r\n 20 30\r\n / \\\r\n 40 60\r\nOutput:\r\n40 20 60 10 30 \r\n30 10 60 20 40\r\n\r\nExplanation: DLL would be 40<=>20<=>60<=>10<=>30.\r\n\r\nExpected Time Complexity: O(no. of nodes)\r\nExpected Space Complexity: O(height of the tree)\r\n\r\nConstraints:\r\n1 ≤ Number of nodes ≤ 10^5\r\n0 ≤ Data of a node ≤ 10^5","shortMessageHtmlLink":"Create 15-09-2024.py"}},{"before":"9aca2c3ae6982fb26dc655eda761b907e8e7f96d","after":"e296fe86dd9443aa289ff2294fa25f5b06a77ba0","ref":"refs/heads/main","pushedAt":"2024-09-14T06:36:13.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 14-09-2024.py\n\nAlternate positive and negative numbers\r\nDifficulty: EasyAccuracy: 33.86%Submissions: 182K+Points: 2\r\n\r\nGiven an unsorted array arr containing both positive and negative numbers. Your task is to create an array of alternate positive and negative numbers without changing the relative order of positive and negative numbers.\r\nNote: Array should start with a positive number and 0 (zero) should be considered a positive element.\r\n\r\nExamples:\r\n\r\nInput: arr[] = [9, 4, -2, -1, 5, 0, -5, -3, 2]\r\nOutput: 9 -2 4 -1 5 -5 0 -3 2\r\nExplanation: Positive elements : [9,4,5,0,2]\r\nNegative elements : [-2,-1,-5,-3]\r\nAs we need to maintain the relative order of postive elements and negative elements we will pick each element from the positive and negative and will store them. If any of the positive and negative numbersare completed. we will continue with the remaining signed elements.\r\nThe output is 9,-2,4,-1,5,-5,0,-3,2.\r\n\r\nInput: arr[] = [-5, -2, 5, 2, 4, 7, 1, 8, 0, -8]\r\nOutput: 5 -5 2 -2 4 -8 7 1 8 0\r\nExplanation : Positive elements : [5,2,4,7,1,8,0]\r\nNegative elements : [-5,-2,-8]\r\nThe output is 5, -5, 2, -2, 4, -8, 7, 1, 8, 0.\r\n\r\nExpected Time Complexity: O(n)\r\nExpected Auxiliary Space: O(n)\r\n\r\nConstraints:\r\n1 ≤ arr.size() ≤ 10^7\r\n-10^6 ≤ arr[i] ≤ 10^7","shortMessageHtmlLink":"Create 14-09-2024.py"}},{"before":"8b5cbdf8aca3b8da79dd7cc694130558bbdaa533","after":"9aca2c3ae6982fb26dc655eda761b907e8e7f96d","ref":"refs/heads/main","pushedAt":"2024-09-12T19:06:28.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 13-09-2024.py\n\nMirror Tree\r\nDifficulty: EasyAccuracy: 72.67%Submissions: 185K+Points: 2\r\n\r\nGiven a Binary Tree, convert it into its mirror.\r\nMirrorTree1 \r\n\r\nExamples:\r\n\r\nInput:\r\n 1\r\n / \\\r\n 2 3\r\nOutput: 3 1 2\r\nExplanation: The tree is\r\n 1 (mirror) 1\r\n / \\ => / \\\r\n2 3 3 2\r\nThe inorder of mirror is 3 1 2\r\n\r\nInput:\r\n 10\r\n / \\\r\n 20 30\r\n / \\\r\n 40 60\r\nOutput: 30 10 60 20 40\r\nExplanation: The tree is\r\n 10 10\r\n / \\ (mirror) / \\\r\n 20 30 => 30 20\r\n / \\ / \\\r\n 40 60 60 40\r\nThe inroder traversal of mirror is\r\n30 10 60 20 40.\r\n\r\nExpected Time Complexity: O(N).\r\nExpected Auxiliary Space: O(Height of the Tree).\r\n\r\nConstraints:\r\n1 ≤ Number of nodes ≤ 10^5\r\n1 ≤ Data of a node ≤ 10^5","shortMessageHtmlLink":"Create 13-09-2024.py"}},{"before":"7374d583cb4efd173fc6b741f74f04e9dd953d29","after":"8b5cbdf8aca3b8da79dd7cc694130558bbdaa533","ref":"refs/heads/main","pushedAt":"2024-09-12T08:33:04.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 12-09-2024.py\n\nMiddle of a Linked List\r\nDifficulty: EasyAccuracy: 57.93%Submissions: 332K+Points: 2\r\n\r\nGiven the head of a linked list, the task is to find the middle. For example, the middle of 1-> 2->3->4->5 is 3. If there are two middle nodes (even count), return the second middle. For example, middle of 1->2->3->4->5->6 is 4.\r\n\r\nExamples:\r\n\r\nInput: Linked list: 1->2->3->4->5\r\nOutput: 3\r\n\r\nExplanation: The given linked list is 1->2->3->4->5 and its middle is 3.\r\n\r\nInput: Linked list: 2->4->6->7->5->1\r\nOutput: 7 \r\n\r\nExplanation: The given linked list is 2->4->6->7->5->1 and its middle is 7.\r\n\r\nExpected Time Complexity: O(n)\r\nExpected Auxiliary Space: O(1)\r\n\r\nConstraints:\r\n1 <= no. of nodes <= 10^5","shortMessageHtmlLink":"Create 12-09-2024.py"}},{"before":"ccb37c783c0b8fe4ee032fac8f3885dbba7c25d0","after":"7374d583cb4efd173fc6b741f74f04e9dd953d29","ref":"refs/heads/main","pushedAt":"2024-09-11T08:54:53.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 11-09-2024.py\n\nMinimum Cost of ropes\r\nDifficulty: EasyAccuracy: 42.73%Submissions: 205K+Points: 2\r\n\r\nGiven an array arr containing the lengths of the different ropes, we need to connect these ropes to form one rope. The cost to connect two ropes is equal to sum of their lengths. The task is to connect the ropes with minimum cost. \r\n\r\nExamples:\r\n\r\nInput: arr[] = [4, 3, 2, 6]\r\nOutput: 29\r\nExplanation: We can connect the ropes in following ways.\r\n1) First connect ropes of lengths 2 and 3. Which makes the array [4, 5, 6]. Cost of this operation 2 + 3 = 5. \r\n2) Now connect ropes of lengths 4 and 5. Which makes the array [9, 6]. Cost of this operation 4 + 5 = 9.\r\n3) Finally connect the two ropes and all ropes have connected. Cost of this operation 9 + 6 =15\r\nTotal cost for connecting all ropes is 5 + 9 + 15 = 29. This is the optimized cost for connecting ropes. \r\nOther ways of connecting ropes would always have same or more cost. For example, if we connect 4 and 6 first (we get three rope of 3, 2 and 10), then connect 10 and 3 (we gettwo rope of 13 and 2). Finally we connect 13 and 2. Total cost in this way is 10 + 13 + 15 = 38.\r\n\r\nInput: arr[] = [4, 2, 7, 6, 9]\r\nOutput: 62 \r\nExplanation: First, connect ropes 4 and 2, which makes the array [6, 7, 6, 9]. Cost of this operation 4 + 2 = 6. \r\nNext, add ropes 6 and 6, which results in [12, 7, 9]. Cost of this operation 6 + 6 = 12.\r\nThen, add 7 and 9, which makes the array [12,16]. Cost of this operation 7 + 9 = 16. And\r\nfinally, add these two which gives [28]. Hence, the total cost is 6 + 12 + 16 + 28 = 62.\r\n\r\nExpected Time Complexity: O(n logn)\r\nExpected Auxilliary Space: O(n)\r\n\r\nConstraints:\r\n1 ≤ arr.size() ≤ 20^5\r\n1 ≤ arr[i] ≤ 10^6","shortMessageHtmlLink":"Create 11-09-2024.py"}},{"before":"decaebd0146099f8f97518397708868c03389181","after":"ccb37c783c0b8fe4ee032fac8f3885dbba7c25d0","ref":"refs/heads/main","pushedAt":"2024-09-10T12:46:39.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 10-09-2024.py\n\nCircle of strings\r\nDifficulty: HardAccuracy: 15.56%Submissions: 70K+Points: 8\r\n\r\nGiven an array arr of lowercase strings, determine if the strings can be chained together to form a circle.\r\nA string X can be chained together with another string Y if the last character of X is the same as the first character of Y. If every string of the array can be chained with exactly two strings of the array(one with the first character and the second with the last character of the string), it will form a circle.\r\n\r\nFor example, for the array arr[] = {\"for\", \"geek\", \"rig\", \"kaf\"} the answer will be Yes as the given strings can be chained as \"for\", \"rig\", \"geek\" and \"kaf\"\r\n\r\nExamples\r\n\r\nInput: arr[] = [\"abc\", \"bcd\", \"cdf\"]\r\nOutput: 0\r\nExplaination: These strings can't form a circle because no string has 'd'at the starting index.\r\n\r\nInput: arr[] = [\"ab\" , \"bc\", \"cd\", \"da\"]\r\nOutput: 1\r\nExplaination: These strings can form a circle of strings.\r\n\r\nExpected Time Complexity: O(n)\r\nExpected Auxiliary Space: O(n)\r\n\r\nConstraints: \r\n1 ≤ length of strings ≤ 20","shortMessageHtmlLink":"Create 10-09-2024.py"}},{"before":"6513aad049c2d74516c3f127494d31e00e898ebb","after":"decaebd0146099f8f97518397708868c03389181","ref":"refs/heads/main","pushedAt":"2024-09-09T07:11:25.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 09-09-2024.py\n\nSort 0s, 1s and 2s\r\nDifficulty: EasyAccuracy: 50.58%Submissions: 684K+Points: 2\r\n\r\nGiven an array arr containing only 0s, 1s, and 2s. Sort the array in ascending order.\r\n\r\nExamples:\r\n\r\nInput: arr[]= [0, 2, 1, 2, 0]\r\nOutput: 0 0 1 2 2\r\nExplanation: 0s 1s and 2s are segregated into ascending order.\r\n\r\nInput: arr[] = [0, 1, 0]\r\nOutput: 0 0 1\r\nExplanation: 0s 1s and 2s are segregated into ascending order.\r\n\r\nExpected Time Complexity: O(n)\r\nExpected Auxiliary Space: O(1)\r\n\r\nConstraints:\r\n1 <= arr.size() <= 10^6\r\n0 <= arr[i] <= 2","shortMessageHtmlLink":"Create 09-09-2024.py"}},{"before":"57e9cfb09e4c861b6649331fe6e0e25e5494e2c5","after":"6513aad049c2d74516c3f127494d31e00e898ebb","ref":"refs/heads/main","pushedAt":"2024-09-07T19:56:20.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 08-09-2024.py\n\nMinimum Jumps\r\nDifficulty: MediumAccuracy: 11.91%Submissions: 849K+Points: 4\r\n\r\nGiven an array arr[] of non-negative integers. Each array element represents the maximum length of the jumps that can be made forward from that element. This means if arr[i] = x, then we can jump any distance y such that y ≤ x.\r\nFind the minimum number of jumps to reach the end of the array starting from the first element. If an element is 0, then you cannot move through that element.\r\nNote: Return -1 if you can't reach the end of the array.\r\n\r\nExamples : \r\n\r\nInput: arr[] = {1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9}\r\nOutput: 3 \r\nExplanation:First jump from 1st element to 2nd element with value 3. From here we jump to 5th element with value 9, and from here we will jump to the last. \r\n\r\nInput: arr = {1, 4, 3, 2, 6, 7}\r\nOutput: 2 \r\nExplanation: First we jump from the 1st to 2nd element and then jump to the last element.\r\n\r\nInput: arr = {0, 10, 20}\r\nOutput: -1\r\nExplanation: We cannot go anywhere from the 1st element.\r\n\r\nExpected Time Complexity: O(n)\r\nExpected Space Complexity: O(1)\r\n\r\nConstraints:\r\n0 ≤ arr[i] ≤ 10^5\r\n2 ≤ arr.size() ≤ 10^6","shortMessageHtmlLink":"Create 08-09-2024.py"}},{"before":"8753116ac685ac7d0ee0b6f3b73690bd93ec2c57","after":"57e9cfb09e4c861b6649331fe6e0e25e5494e2c5","ref":"refs/heads/main","pushedAt":"2024-09-07T04:14:57.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 07-09-2024.py\n\nNth Natural Number\r\nDifficulty: MediumAccuracy: 29.99%Submissions: 56K+Points: 4\r\n\r\nGiven a positive integer n. You have to find nth natural number after removing all the numbers containing the digit 9.\r\n\r\nExamples :\r\n\r\nInput: n = 8\r\nOutput: 8\r\nExplanation: After removing natural numbers which contains digit 9, first 8 numbers are 1,2,3,4,5,6,7,8 and 8th number is 8.\r\n\r\nInput: n = 9\r\nOutput: 10\r\nExplanation: After removing natural numbers which contains digit 9, first 9 numbers are 1,2,3,4,5,6,7,8,10 and 9th number is 10.\r\n\r\nExpected Time Complexity: O(logn)\r\nExpected Auxiliary Space: O(1)\r\n\r\n\r\nConstraints:\r\n1 ≤ n ≤ 10^9","shortMessageHtmlLink":"Create 07-09-2024.py"}},{"before":"3e130ef62f01792dbeb828c696286fd5ca4708e9","after":"8753116ac685ac7d0ee0b6f3b73690bd93ec2c57","ref":"refs/heads/main","pushedAt":"2024-09-06T15:24:11.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 06-09-2024.py\n\nKadane's Algorithm\r\nDifficulty: MediumAccuracy: 36.28%Submissions: 965K+Points: 4\r\n\r\nGiven an integer array arr[]. Find the contiguous sub-array(containing at least one number) that has the maximum sum and return its sum.\r\n\r\nExamples:\r\n\r\nInput: arr[] = [1, 2, 3, -2, 5]\r\nOutput: 9\r\nExplanation: Max subarray sum is 9 of elements (1, 2, 3, -2, 5) which is a contiguous subarray.\r\n\r\nInput: arr[] = [-1, -2, -3, -4]\r\nOutput: -1\r\nExplanation: Max subarray sum is -1 of element (-1)\r\n\r\nInput: arr[] = [5, 4, 7]\r\nOutput: 16\r\nExplanation: Max subarray sum is 16 of element (5, 4, 7)\r\n\r\nExpected Time Complexity: O(n)\r\nExpected Auxiliary Space: O(1)\r\n\r\nConstraints:\r\n1 ≤ arr.size() ≤ 10^5\r\n-10^7 ≤ arr[i] ≤ 10^7","shortMessageHtmlLink":"Create 06-09-2024.py"}},{"before":"9477820997fd6f0dd874b145feca7a32f1eaa025","after":"3e130ef62f01792dbeb828c696286fd5ca4708e9","ref":"refs/heads/main","pushedAt":"2024-09-05T06:38:12.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 05-09-2024.py\n\nBack to Explore Page\r\nMissing in Array\r\nDifficulty: EasyAccuracy: 29.59%Submissions: 1.2MPoints: 2\r\n\r\nGiven an array arr of size n−1 that contains distinct integers in the range of 1 to n (inclusive), find the missing element. The array is a permutation of size n with one element missing. Return the missing element.\r\n\r\nExamples:\r\n\r\nInput: n = 5, arr[] = [1,2,3,5]\r\nOutput: 4\r\nExplanation : All the numbers from 1 to 5 are present except 4.\r\n\r\nInput: n = 2, arr[] = [1]\r\nOutput: 2\r\nExplanation : All the numbers from 1 to 2 are present except 2.\r\n\r\nExpected Time Complexity: O(n)\r\nExpected Auxiliary Space: O(1)\r\n\r\nConstraints:\r\n1 ≤ n ≤ 10^5\r\n1 ≤ arr[i] ≤ n","shortMessageHtmlLink":"Create 05-09-2024.py"}},{"before":"786752387d98031091779cfd885b19e39dd0d9c3","after":"9477820997fd6f0dd874b145feca7a32f1eaa025","ref":"refs/heads/main","pushedAt":"2024-09-04T05:02:02.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 04-09-2024.py\n\nCount ways to N'th Stair(Order does not matter)\r\nDifficulty: MediumAccuracy: 50.49%Submissions: 51K+Points: 4\r\n\r\nThere are n stairs, and a person standing at the bottom wants to reach the top. The person can climb either 1 stair or 2 stairs at a time. Count the number of ways, the person can reach the top (order does not matter).\r\nNote: Order does not matter means for n = 4:- {1 2 1},{2 1 1},{1 1 2} are considered same.\r\n\r\nExamples :\r\n\r\nInput: n = 4\r\nOutput: 3\r\nExplanation: Three ways to reach at 4th stair. They are {1, 1, 1, 1}, {1, 1, 2}, {2, 2}.\r\n\r\nInput: n = 5\r\nOutput: 3\r\nExplanation: Three ways to reach at 5th stair. They are {1, 1, 1, 1, 1}, {1, 1, 2, 1} and {1, 2, 2}.\r\n\r\nExpected Time Complexity: O(n)\r\nExpected Space Complexity: O(n)\r\n\r\nConstraints:\r\n1 ≤ n ≤ 10^4","shortMessageHtmlLink":"Create 04-09-2024.py"}},{"before":"b0047c407556999f5edf89aed99449d80b8bd216","after":"786752387d98031091779cfd885b19e39dd0d9c3","ref":"refs/heads/main","pushedAt":"2024-09-03T14:22:13.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 03-09-2024.py\n\nMinimum number of deletions and insertions\r\nDifficulty: MediumAccuracy: 65.29%Submissions: 58K+Points: 4\r\n\r\nGiven two strings str1 and str2. The task is to remove or insert the minimum number of characters from/in str1 so as to transform it into str2. It could be possible that the same character needs to be removed/deleted from one point of str1 and inserted to some another point.\r\n\r\nExamples :\r\n\r\nInput: str1 = \"heap\", str2 = \"pea\"\r\nOutput: 3\r\nExplanation: 2 deletions and 1 insertion.\r\np and h deleted from heap. Then, p is inserted at the beginning.\r\nOne thing to note, though p was required yet it was removed/deleted first from its position and then it is inserted to some other position. Thus, p contributes one to the deletion_count and one to the insertion_count.\r\n\r\nInput : str1 = \"geeksforgeeks\", str2 = \"geeks\"\r\nOutput: 8\r\nExplanation: 8 deletions, i.e. remove all characters of the string \"forgeeks\".\r\n\r\nExpected Time Complexity: O(|str1|*|str2|)\r\nExpected Space Complexity: O(|str1|*|str2|)\r\n\r\nConstraints:\r\n1 ≤ |str1|, |str2| ≤ 1000\r\nAll the characters are lowercase English alphabets","shortMessageHtmlLink":"Create 03-09-2024.py"}},{"before":"4e026705dee92b20417013914e4fbc47801f64e2","after":"b0047c407556999f5edf89aed99449d80b8bd216","ref":"refs/heads/main","pushedAt":"2024-09-02T12:07:30.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 02-09-2024.py\n\nMinimum Cost Path\r\nDifficulty: HardAccuracy: 26.99%Submissions: 96K+Points: 8\r\n\r\nGiven a square grid of size N, each cell of which contains an integer cost that represents a cost to traverse through that cell, we need to find a path from the top left cell to the bottom right cell by which the total cost incurred is minimum.\r\nFrom the cell (i,j) we can go (i,j-1), (i, j+1), (i-1, j), (i+1, j). \r\n\r\nExamples :\r\n\r\nInput: grid = {{9,4,9,9},{6,7,6,4},{8,3,3,7},{7,4,9,10}}\r\nOutput: 43\r\nExplanation: The grid is-\r\n9 4 9 9\r\n6 7 6 4\r\n8 3 3 7\r\n7 4 9 10\r\nThe minimum cost is-\r\n9 + 4 + 7 + 3 + 3 + 7 + 10 = 43.\r\n\r\nInput: grid = {{4,4},{3,7}}\r\nOutput: 14\r\nExplanation: The grid is-\r\n4 4\r\n3 7\r\nThe minimum cost is- 4 + 3 + 7 = 14.\r\n\r\nExpected Time Complexity: O(n^2*log(n))\r\nExpected Auxiliary Space: O(n^2) \r\n Constraints:\r\n1 ≤ n ≤ 500\r\n1 ≤ cost of cells ≤ 500","shortMessageHtmlLink":"Create 02-09-2024.py"}},{"before":"af2736b57b867f9187dd533ce3e93e7a59b9cca9","after":"4e026705dee92b20417013914e4fbc47801f64e2","ref":"refs/heads/main","pushedAt":"2024-09-01T12:08:59.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 01-09-2024.py\n\nMax sum path in two arrays\r\nDifficulty: MediumAccuracy: 30.9%Submissions: 59K+Points: 4\r\n\r\nGiven two sorted arrays of distinct integers arr1 and arr2. Each array may have some elements in common with the other array. Find the maximum sum of a path from the beginning of any array to the end of any array. You can switch from one array to another array only at the common elements.\r\n\r\nNote: When we switch from one array to other, we need to consider the common element only once in the result.\r\n\r\nExamples : \r\n\r\nInput: arr1 = [2, 3, 7, 10, 12] , arr2 = [1, 5, 7, 8]\r\nOutput: 35\r\nExplanation: The path will be 1+5+7+10+12 = 35, where 1 and 5 come from arr2 and then 7 is common so we switch to arr1 and add 10 and 12.\r\n\r\nInput: arr1 = [1, 2, 3] , arr2[] = [3, 4, 5]\r\nOutput: 15\r\nExplanation: The path will be 1+2+3+4+5=15.\r\n\r\nExpected Time Complexity: O(m + n)\r\nExpected Auxiliary Space: O(1)\r\n\r\nConstraints:\r\n1 <= arr1.size(), arr2.size() <= 10^4\r\n1 <= arr1[i], arr2[i] <= 10^5","shortMessageHtmlLink":"Create 01-09-2024.py"}},{"before":"5f497c6540a78c5df2821d3dde92e46ca1c95ffd","after":"af2736b57b867f9187dd533ce3e93e7a59b9cca9","ref":"refs/heads/main","pushedAt":"2024-08-30T19:52:42.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 31-08-2024.py\n\nSorted subsequence of size 3\r\nDifficulty: MediumAccuracy: 25.95%Submissions: 52K+Points: 4\r\n\r\nYou are given an array arr, you need to find any three elements in it such that arr[i] < arr[j] < arr[k] and i < j < k.\r\n\r\nNote:\r\n\r\n The output will be 1 if the subsequence returned by the function is present in the array arr\r\n If the subsequence is not present in the array then return an empty array, the driver code will print 0.\r\n If the subsequence returned by the function is not in the format as mentioned then the output will be -1.\r\n\r\nExamples :\r\n\r\nInput: arr = [1, 2, 1, 1, 3]\r\nOutput: 1\r\nExplanation: A subsequence 1 2 3 exist.\r\n\r\nInput: arr = [1, 1, 3]\r\nOutput: 0\r\nExplanation: No such Subsequence exist, so empty array is returned (the driver code automatically prints 0 in this case).\r\n\r\nExpected Time Complexity: O(n)\r\nExpected Auxiliary Space: O(n)\r\n\r\nConstraints:\r\n1 <= arr.size() <= 10^5\r\n1 <= arr[i] <= 10^6","shortMessageHtmlLink":"Create 31-08-2024.py"}},{"before":"c57c83491e29072e8321fadb4c7d727b951a872f","after":"5f497c6540a78c5df2821d3dde92e46ca1c95ffd","ref":"refs/heads/main","pushedAt":"2024-08-30T15:08:05.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 30-08-2024.py\n\nN-Queen Problem\r\nDifficulty: HardAccuracy: 35.43%Submissions: 84K+Points: 8\r\n\r\nThe n-queens puzzle is the problem of placing n queens on a (n×n) chessboard such that no two queens can attack each other.\r\nGiven an integer n, find all distinct solutions to the n-queens puzzle. Each solution contains distinct board configurations of the n-queens placement, where the solutions are a permutation of [1,2,3..n] in increasing order, here the number in the ith place denotes that the ith-column queen is placed in the row with that number.","shortMessageHtmlLink":"Create 30-08-2024.py"}},{"before":"030f8a2152c4b11a21b610619d2d580a0d62c3f5","after":"c57c83491e29072e8321fadb4c7d727b951a872f","ref":"refs/heads/main","pushedAt":"2024-08-29T13:30:09.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 29-08-2024.py\n\nFind length of Loop\r\nDifficulty: EasyAccuracy: 44.26%Submissions: 180K+Points: 2\r\n\r\nGiven the head of a linked list, determine whether the list contains a loop. If a loop is present, return the number of nodes in the loop, otherwise return 0.\r\n\r\nNote: 'c' is the position of the node which is the next pointer of the last node of the linkedlist. If c is 0, then there is no loop.\r\n\r\nExamples:\r\n\r\nInput: LinkedList: 25->14->19->33->10->21->39->90->58->45, c = 4\r\nOutput: 7\r\nExplanation: The loop is from 33 to 45. So length of loop is 33->10->21->39-> 90->58->45 = 7. \r\nThe number 33 is connected to the last node of the linkedlist to form the loop because according to the input the 4th node from the beginning(1 based indexing) \r\nwill be connected to the last node for the loop.\r\n \r\n\r\nInput: LinkedList: 5->4, c = 0\r\nOutput: 0\r\nExplanation: There is no loop.\r\n\r\nExpected Time Complexity: O(n)\r\nExpected Auxiliary Space: O(1)\r\n\r\nConstraints:\r\n1 <= no. of nodes <= 10^6\r\n0 <= node.data <=10^6\r\n0 <= c<= n-1","shortMessageHtmlLink":"Create 29-08-2024.py"}},{"before":"b6edba6f35d9dd7148b6d97e162c7fb6d2d783c9","after":"030f8a2152c4b11a21b610619d2d580a0d62c3f5","ref":"refs/heads/main","pushedAt":"2024-08-28T15:54:56.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 28-08-2024.py\n\nSorting Elements of an Array by Frequency\r\nDifficulty: MediumAccuracy: 44.93%Submissions: 67K+Points: 4\r\n\r\nGiven an array of integers arr, sort the array according to the frequency of elements, i.e. elements that have higher frequency comes first. If the frequencies of two elements are the same, then the smaller number comes first.\r\n\r\nExamples :\r\n\r\nInput: arr[] = [5, 5, 4, 6, 4]\r\nOutput: [4, 4, 5, 5, 6]\r\nExplanation: The highest frequency here is 2. Both 5 and 4 have that frequency. Now since the frequencies are the same the smaller element comes first. So 4 4 comes first then comes 5 5. Finally comes 6. The output is 4 4 5 5 6.\r\n\r\nInput: arr[] = [9, 9, 9, 2, 5]\r\nOutput: [9, 9, 9, 2, 5]\r\nExplanation: The highest frequency here is 3. Element 9 has the highest frequency So 9 9 9 comes first. Now both 2 and 5 have the same frequency. So we print smaller elements first. The output is 9 9 9 2 5.\r\n\r\nExpected Time Complexity: O(n*logn)\r\nExpected Space Complexity: O(n)\r\n\r\nConstraints:\r\n1 ≤ arr.size() ≤ 10^5\r\n1 ≤ arr[i]≤ 10^5","shortMessageHtmlLink":"Create 28-08-2024.py"}},{"before":"44288b21cc8f02438f82cc71c8527530ee91119d","after":"b6edba6f35d9dd7148b6d97e162c7fb6d2d783c9","ref":"refs/heads/main","pushedAt":"2024-08-27T05:59:49.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 27-08-2024.py\n\nMaximum Difference\r\nDifficulty: MediumAccuracy: 33.3%Submissions: 56K+Points: 4\r\n\r\nGiven an integer array arr of integers, the task is to find the maximum absolute difference between the nearest left smaller element and the nearest right smaller element of every element in array arr. If for any component of the arr, the nearest smaller element doesn't exist then consider it as 0.\r\n\r\nExamples :\r\n\r\nInput: arr = [2, 1, 8]\r\nOutput: 1\r\nExplanation: left smaller array ls = [0, 0, 1], right smaller array rs = [1, 0, 0]. Maximum Diff of abs(ls[i] - rs[i]) = 1\r\n\r\nInput: arr = [2, 4, 8, 7, 7, 9, 3]\r\nOutput: 4\r\nExplanation: left smaller array ls = [0, 2, 4, 4, 4, 7, 2], right smaller rs = [0, 3, 7, 3, 3, 3, 0]. Maximum Diff of abs(ls[i] - rs[i]) = abs(7 - 3) = 4\r\n\r\nExpected Time Complexity: O(n)\r\nExpected Space Complexity: O(n)\r\n\r\nConstraints:\r\n1 <= arr.size() <= 10^6\r\n1<= arr[i] <=10^9","shortMessageHtmlLink":"Create 27-08-2024.py"}},{"before":"1eaf814ccb8c1bd30bcfcba54ed8d93c86cb7709","after":"44288b21cc8f02438f82cc71c8527530ee91119d","ref":"refs/heads/main","pushedAt":"2024-08-26T14:12:25.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 26-08-2024.py\n\nWildcard Pattern Matching\r\nDifficulty: HardAccuracy: 31.13%Submissions: 68K+Points: 8\r\n\r\nGiven two strings pattern and str which may be of different size, You have to return 1 if the wildcard pattern i.e. pattern, matches with str else return 0. All characters of the string str and pattern always belong to the Alphanumeric characters.\r\n\r\nThe wildcard pattern can include the characters ? and *\r\n‘?’ – matches any single character.\r\n‘*’ – Matches any sequence of characters (including the empty sequence).\r\n\r\nNote: The matching should cover the entire str (not partial str).\r\n\r\nExamples:\r\n\r\nInput: pattern = \"ba*a?\", str = \"baaabab\"\r\nOutput: 1\r\nExplanation: replace '*' with \"aab\" and \r\n'?' with 'b'.\r\n\r\nInput: pattern = \"a*ab\", str = \"baaabab\"\r\nOutput: 0\r\nExplanation: Because in string pattern character 'a' at first position,\r\npattern and str can't be matched. \r\n\r\nExpected Time Complexity: O(n*m)\r\nExpected Auxiliary Space: O(n*m)\r\n\r\nConstraints:\r\n1 <= length of(str, pattern) <= 200","shortMessageHtmlLink":"Create 26-08-2024.py"}},{"before":"961ae68b7c63eff85acaf667de2a0f31891e97d8","after":"1eaf814ccb8c1bd30bcfcba54ed8d93c86cb7709","ref":"refs/heads/main","pushedAt":"2024-08-25T09:26:24.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 25-08-2024.py\n\nNumber of pairs\r\nDifficulty: MediumAccuracy: 21.82%Submissions: 67K+Points: 4\r\n\r\nGiven two positive integer arrays arr and brr, find the number of pairs such that x^y > y^x (raised to power of) where x is an element from arr and y is an element from brr.\r\n\r\nExamples :\r\n\r\nInput: arr[] = [2, 1, 6], brr[] = [1, 5]\r\nOutput: 3\r\nExplanation: The pairs which follow x^y > y^x are: 2^1 > 1^2, 2^5 > 5^2 and 6^1 > 1^6 .\r\n\r\nInput: arr[] = [2 3 4 5], brr[] = [1 2 3]\r\nOutput: 5\r\nExplanation: The pairs which follow x^y > y^x are: 2^1 > 1^2 , 3^1 > 1^3 , 3^2 > 2^3 , 4^1 > 1^4 , 5^1 > 1^5 .\r\n\r\nExpected Time Complexity: O((N + M)log(N)).\r\nExpected Auxiliary Space: O(1).\r\n\r\nConstraints:\r\n1 ≤ arr.size(), brr.size() ≤ 10^5\r\n1 ≤ brr[i], arr[i] ≤ 10^3","shortMessageHtmlLink":"Create 25-08-2024.py"}},{"before":"8e636d3bb52bb1b726b6a7d65cf69aa087e1482b","after":"961ae68b7c63eff85acaf667de2a0f31891e97d8","ref":"refs/heads/main","pushedAt":"2024-08-24T07:16:26.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 24-08-2024.py\n\n0 - 1 Knapsack Problem\r\nDifficulty: MediumAccuracy: 31.76%Submissions: 423K+Points: 4\r\n\r\nYou are given weights and values of items, and put these items in a knapsack of capacity W to get the maximum total value in the knapsack. Note that we have only one quantity of each item.\r\nIn other words, given two integer arrays val and wt which represent values and weights associated with items respectively. Also given an integer W which represents knapsack capacity, find out the maximum sum values subset of val[] such that the sum of the weights of the corresponding subset is smaller than or equal to W. You cannot break an item, either pick the complete item or don't pick it (0-1 property).\r\n\r\nExamples :\r\n\r\nInput: W = 4, val[] = {1,2,3}, wt[] = {4,5,1}\r\nOutput: 3\r\nExplanation: Choose the last item that weighs 1 unit and holds a value of 3. \r\n\r\nInput: W = 3, val[] = {1,2,3}, wt[] = {4,5,6}\r\nOutput: 0\r\nExplanation: Every item has a weight exceeding the knapsack's capacity (3).\r\n\r\nExpected Time Complexity: O(N*W).\r\nExpected Auxiliary Space: O(N*W)\r\n\r\nConstraints:\r\n2 ≤ N ≤ 1000\r\n1 ≤ W ≤ 1000\r\n1 ≤ wt[i] ≤ 1000\r\n1 ≤ val[i] ≤ 1000","shortMessageHtmlLink":"Create 24-08-2024.py"}},{"before":"fddb636813d89f65d15a7d32ce82ea07bd714468","after":"8e636d3bb52bb1b726b6a7d65cf69aa087e1482b","ref":"refs/heads/main","pushedAt":"2024-08-23T08:02:16.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 23-08-2024.py\n\nLeft View of Binary Tree\r\nDifficulty: EasyAccuracy: 33.74%Submissions: 503K+Points: 2\r\n\r\nGiven a Binary Tree, return Left view of it. Left view of a Binary Tree is set of nodes visible when tree is visited from Left side. The task is to complete the function leftView(), which accepts root of the tree as argument. If no left view is possible, return an empty tree.\r\n\r\nLeft view of following tree is 1 2 4 8.\r\n\r\n 1\r\n / \\\r\n 2 3\r\n / \\ / \\\r\n 4 5 6 7\r\n \\\r\n 8 \r\n\r\nExamples :\r\n\r\nInput:\r\n 1\r\n / \\\r\n3 2\r\nOutput: 1 3\r\n\r\nInput:\r\n\r\nOutput: 10 20 40\r\n\r\nExpected Time Complexity: O(N).\r\nExpected Auxiliary Space: O(N).\r\n\r\nConstraints:\r\n0 <= Number of nodes <= 10^5\r\n0 <= Data of a node <= 10^5","shortMessageHtmlLink":"Create 23-08-2024.py"}},{"before":"f197b1869995f6289ae33e8a073d4c2cf825a686","after":"fddb636813d89f65d15a7d32ce82ea07bd714468","ref":"refs/heads/main","pushedAt":"2024-08-22T04:56:39.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 22-08-2024.py\n\nAlien Dictionary\r\nDifficulty: HardAccuracy: 47.81%Submissions: 114K+Points: 8\r\n\r\nGiven a sorted dictionary of an alien language having N words and k starting alphabets of standard dictionary. Find the order of characters in the alien language.\r\nNote: Many orders may be possible for a particular test case, thus you may return any valid order and output will be 1 if the order of string returned by the function is correct else 0 denoting incorrect string returned.\r\n \r\n\r\nExamples :\r\n\r\nInput: N = 5, K = 4, dict = {\"baa\",\"abcd\",\"abca\",\"cab\",\"cad\"}\r\nOutput: 1\r\nExplanation: Here order of characters is 'b', 'd', 'a', 'c' Note that words are sorted and in the given language \"baa\" comes before \"abcd\", therefore 'b' is before 'a' in output.\r\nSimilarly we can find other orders.\r\n\r\nInput: N = 3, K = 3, dict = {\"caa\",\"aaa\",\"aab\"}\r\nOutput: 1\r\nExplanation: Here order of characters is 'c', 'a', 'b' Note that words are sorted and in the given language \"caa\" comes before \"aaa\", therefore 'c' is before 'a' in output.\r\nSimilarly we can find other orders.\r\n\r\nExpected Time Complexity: O(N * |S| + K) , where |S| denotes maximum length.\r\nExpected Space Compelxity: O(K)\r\n\r\n\r\nConstraints:\r\n1 ≤ N≤ 10^4\r\n1 ≤ K ≤ 26\r\n1 ≤ Length of words ≤ 50","shortMessageHtmlLink":"Create 22-08-2024.py"}},{"before":"301a34aa355bc5f22a3a10089e7a4a560856a809","after":"f197b1869995f6289ae33e8a073d4c2cf825a686","ref":"refs/heads/main","pushedAt":"2024-08-21T03:02:40.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 21-08-2024.py\n\nShortest path in Undirected Graph\r\nDifficulty: MediumAccuracy: 49.98%Submissions: 81K+Points: 4\r\n\r\nYou are given an Undirected Graph having unit weight of the edges, find the shortest path from src to all the vertex and if it is unreachable to reach any vertex, then return -1 for that vertex.\r\n\r\nExamples :\r\n\r\nInput:\r\nn = 9, m = 10\r\nedges=[[0,1],[0,3],[3,4],[4,5],[5,6],[1,2],[2,6],[6,7],[7,8],[6,8]] \r\nsrc=0\r\nOutput:\r\n0 1 2 1 2 3 3 4 4\r\n\r\nInput:\r\nn = 4, m = 2\r\nedges=[[1,3],[3,0]] \r\nsrc=3\r\nOutput:\r\n1 1 -1 0\r\n\r\nConstraint:\r\n1<=n,m<=10^4\r\n0<=edges[i][j]<=n-1\r\n\r\nExpected Time Complexity: O(N + E), where N is the number of nodes and E is the edges\r\nExpected Space Complexity: O(N)","shortMessageHtmlLink":"Create 21-08-2024.py"}},{"before":"c934d92f0ccf76a88ad3f491eb3a80f369509fd2","after":"301a34aa355bc5f22a3a10089e7a4a560856a809","ref":"refs/heads/main","pushedAt":"2024-08-21T03:01:38.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Rename 21-08-2024.py to 20-08-2024.py","shortMessageHtmlLink":"Rename 21-08-2024.py to 20-08-2024.py"}},{"before":"a997abf2b63c4238e3c1c784878b1f3a02a9b1fa","after":"c934d92f0ccf76a88ad3f491eb3a80f369509fd2","ref":"refs/heads/main","pushedAt":"2024-08-20T13:53:28.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 21-08-2024.py\n\nBurning Tree\r\nDifficulty: HardAccuracy: 53.53%Submissions: 75K+Points: 8\r\n\r\nGiven a binary tree and a node data called target. Find the minimum time required to burn the complete binary tree if the target is set on fire. It is known that in 1 second all nodes connected to a given node get burned. That is its left child, right child, and parent.\r\nNote: The tree contains unique values.\r\n\r\n\r\nExamples : \r\n\r\nInput: \r\n 1\r\n / \\\r\n 2 3\r\n / \\ \\\r\n 4 5 6\r\n / \\ \\\r\n 7 8 9\r\n \\\r\n 10\r\nTarget Node = 8\r\nOutput: 7\r\nExplanation: If leaf with the value 8 is set on fire. \r\nAfter 1 sec: 5 is set on fire.\r\nAfter 2 sec: 2, 7 are set to fire.\r\nAfter 3 sec: 4, 1 are set to fire.\r\nAfter 4 sec: 3 is set to fire.\r\nAfter 5 sec: 6 is set to fire.\r\nAfter 6 sec: 9 is set to fire.\r\nAfter 7 sec: 10 is set to fire.\r\nIt takes 7s to burn the complete tree.\r\n\r\nInput: \r\n 1\r\n / \\\r\n 2 3\r\n / \\ \\\r\n 4 5 7\r\n / / \r\n 8 10\r\nTarget Node = 10\r\nOutput: 5\r\n\r\n\r\nExpected Time Complexity: O(number of nodes)\r\nExpected Auxiliary Space: O(height of tree)\r\n\r\n\r\nConstraints:\r\n1 ≤ number of nodes ≤ 10^5\r\n\r\n1 ≤ values of nodes ≤ 10^5","shortMessageHtmlLink":"Create 21-08-2024.py"}},{"before":"529f77ceec6a3eaca6b740fd145913415f753c09","after":"a997abf2b63c4238e3c1c784878b1f3a02a9b1fa","ref":"refs/heads/main","pushedAt":"2024-08-18T18:59:50.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 19-08-2024.py\n\nKth Smallest\r\nDifficulty: MediumAccuracy: 35.17%Submissions: 614K+Points: 4\r\n\r\nGiven an array arr[] and an integer k where k is smaller than the size of the array, the task is to find the kth smallest element in the given array. It is given that all array elements are distinct.\r\n\r\nFollow up: Don't solve it using the inbuilt sort function.\r\n\r\nExamples :\r\n\r\nInput: arr[] = [7, 10, 4, 3, 20, 15], k = 3\r\nOutput: 7\r\nExplanation: 3rd smallest element in the given array is 7.\r\n\r\nInput: arr[] = [7, 10, 4, 20, 15], k = 4 \r\nOutput: 15\r\nExplanation: 4th smallest element in the given array is 15.\r\n\r\nExpected Time Complexity: O(n+(max_element) )\r\nExpected Auxiliary Space: O(max_element)\r\n\r\nConstraints:\r\n1 <= arr.size <= 10^6\r\n1<= arr[i] <= 10^6\r\n1 <= k <= n","shortMessageHtmlLink":"Create 19-08-2024.py"}},{"before":"6ead572821dc74b56e800f8dcc630145b2286748","after":"529f77ceec6a3eaca6b740fd145913415f753c09","ref":"refs/heads/main","pushedAt":"2024-08-18T03:32:50.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"dhr7va","name":"Dhruva Kumar","path":"/dhr7va","primaryAvatarUrl":"https://github.com/avatars/u/138505718?s=80&v=4"},"commit":{"message":"Create 18-08-2024.py\n\nSplit an array into two equal Sum subarrays\r\nDifficulty: EasyAccuracy: 66.84%Submissions: 4K+Points: 2\r\n\r\nGiven an array of integers arr, return true if it is possible to split it in two subarrays (without reordering the elements), such that the sum of the two subarrays are equal. If it is not possible then return false.\r\n\r\nExamples:\r\n\r\nInput: arr = [1, 2, 3, 4, 5, 5]\r\nOutput: true\r\nExplanation: In the above example, we can divide the array into two subarrays with eqaul sum. The two subarrays are: [1, 2, 3, 4] and [5, 5]. The sum of both the subarrays are 10. Hence, the answer is true.\r\n\r\nInput: arr = [4, 3, 2, 1]\r\nOutput: false\r\nExplanation: In the above example, we cannot divide the array into two subarrays with eqaul sum. Hence, the answer is false.\r\n\r\nExpected Time Complexity: O(n)\r\nExpected Space Complexity: O(1)\r\n\r\nConstraints:\r\n1<=arr.size()<=10^5 \r\n1<=arr[i]<=10^6","shortMessageHtmlLink":"Create 18-08-2024.py"}}],"hasNextPage":true,"hasPreviousPage":false,"activityType":"all","actor":null,"timePeriod":"all","sort":"DESC","perPage":30,"cursor":"Y3Vyc29yOnYyOpK7MjAyNC0wOS0xNVQwNzozMDozNi4wMDAwMDBazwAAAAS2k0k9","startCursor":"Y3Vyc29yOnYyOpK7MjAyNC0wOS0xNVQwNzozMDozNi4wMDAwMDBazwAAAAS2k0k9","endCursor":"Y3Vyc29yOnYyOpK7MjAyNC0wOC0xOFQwMzozMjo1MC4wMDAwMDBazwAAAASdGMZF"}},"title":"Activity · dhr7va/GeeksforGeeks-POTD-solutions"}