{"id":20206520,"url":"https://github.com/yuvrajchandra/leetcode","last_synced_at":"2025-10-17T16:20:41.173Z","repository":{"id":201662663,"uuid":"302679082","full_name":"Yuvrajchandra/LeetCode","owner":"Yuvrajchandra","description":"This repository contains solution of Leetcode problems (in C++) and key points/takeaways/techniques involved in solving that problem.","archived":false,"fork":false,"pushed_at":"2020-10-30T18:54:52.000Z","size":69,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-13T20:48:45.172Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Yuvrajchandra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-10-09T15:18:41.000Z","updated_at":"2020-10-30T18:54:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"899385d9-ed12-4f15-9531-f4add7e8e859","html_url":"https://github.com/Yuvrajchandra/LeetCode","commit_stats":null,"previous_names":["yuvrajchandra/leetcode"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yuvrajchandra%2FLeetCode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yuvrajchandra%2FLeetCode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yuvrajchandra%2FLeetCode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yuvrajchandra%2FLeetCode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yuvrajchandra","download_url":"https://codeload.github.com/Yuvrajchandra/LeetCode/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241644542,"owners_count":19996177,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T05:24:36.680Z","updated_at":"2025-10-17T16:20:36.131Z","avatar_url":"https://github.com/Yuvrajchandra.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Leetcode\nThis repository contains solution of Leetcode problems (in C++) and key points/takeaways/techniques involved in solving that problem.\n\n\n---\n\n[1480. Running Sum of 1d Array](https://leetcode.com/problems/running-sum-of-1d-array/)\n+ .size() is used to find size of vector.  \n  For eg- int size = myVect.size();\n  \n---\n  \n[1431. Kids With the Greatest Number of Candies](https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/)\n+ To find max element of vector, following syntax is used.  \n  For eg- int max = *max_element(candies.begin(),candies.end());\n    \n---\n\n[1470. Shuffle the Array](https://leetcode.com/problems/shuffle-the-array/)\n+ To intialize multiple variables in for loop following syntax is used:  \n  for(int i=0;j=0;k=0; i\u003cn; i++,j++,k++)\n  \n---\n\n[1512. Number of Good Pairs](https://leetcode.com/problems/number-of-good-pairs/)  \n+ Using for loop as  \n  for(int i=0; i\u003cnums.size(); i++)\n  is **more faster** than using it as-  \n  int sizeOfVector = nums.size();  \n  for(int i=0; i\u003csizeOfVector; i++)  \n  \n---\n\n[1108. Defanging an IP Address](https://leetcode.com/problems/defanging-an-ip-address/)  \n+ Replace characters of String  \n  regex_replace(address, regex(\"[-]\"), \"[.]\")  \n  Using **regex_replace** we can replace the match.  \n  Here, \"255-100-50-0\" will be replaced by \"255[.]100[.]50[.]0\"  \n  Note- It is slow as compared to next method  \n  \n+ See the 2nd approach of this question for faster way to replace.  \n\n---\n \n[771. Jewels and Stones](https://leetcode.com/problems/jewels-and-stones/)\n+ Using for(char \u0026ch1 : Str) is more faster way to use for loop as compared to  \n  for(char \u0026 ch1 : Str) or any other type of for loop.\n  \n---\n\n[1281. Subtract the Product and Sum of Digits of an Integer](https://leetcode.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer/)\n+ Following logic is used to get each digit of a number.  \n```\n          while(n)\n          {\n            int remainder = n%10; \n            n /= 10;\n          }\n```\n\n---\n\n**[IMP]**  \n[1313. Decompress Run-Length Encoded List](https://leetcode.com/problems/decompress-run-length-encoded-list/)\n+ vector insert() function in C++ STL  \n  Following is the syntax of vector insert() :  \n  \n  + vector_name.insert(position, frequency, value);  \n    For eg- ``` vec.insert(vec.end(), 2, 4); ```  \n    \n  + vector_name.insert (position, value);  \n    For More details visit [this](https://www.geeksforgeeks.org/vector-insert-function-in-c-stl/) for more details.\n    \n---\n\n[1389. Create Target Array in the Given Order](https://leetcode.com/problems/create-target-array-in-the-given-order/)\n+ vector_name.insert (position, value);\n\n---\n\n[1486. XOR Operation in an Array](https://leetcode.com/problems/xor-operation-in-an-array/)\n+ XOR of a number with itself results Zero. and XOR of a number with 0 results the number itself.  \n  For eg-  \n         ```\n            2 ^ 2 = 0  \n            4 ^ 0 = 4         \n         ```\n            \n---  \n\n[1295. Find Numbers with Even Number of Digits](https://leetcode.com/problems/find-numbers-with-even-number-of-digits/)\n+ To count number of digits in a number.  \n  ```\n      int noOfDigits = 0;\n      while(num)\n      {\n          noOfDigits++;\n          num/=10;\n      }\n   ```\n   \n---\n\n[1561. Maximum Number of Coins You Can Get](https://leetcode.com/problems/maximum-number-of-coins-you-can-get/)\n+ To sort the vector in descending order, following syntax is used-  \n  ```\n  sort(piles.begin(), piles.end(), greater\u003cint\u003e());\n  ```\n+ To copy a vector to another-\n  ```\n  vector\u003cint\u003e newVec = oldVec;\n  ```\n  \n---\n\n[1630. Arithmetic Subarrays](https://leetcode.com/problems/arithmetic-subarrays/)\n+ vec.end() points to the index equal to the size of the array.  \n+ To create a vector from sub-array of other array following syntax is used:  \n  ```\n  vector\u003cint\u003e newVect(nums.begin()+1, nums.begin()+4+1);\n  // To copy elements of nums indexed between 1 to 4\n  ```\n  Note : +1 is used with 2nd parameter due to given 1st point.\n\n---\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuvrajchandra%2Fleetcode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuvrajchandra%2Fleetcode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuvrajchandra%2Fleetcode/lists"}