DSA
A set of coding questions and solutions in Java/C++. Platforms used - GeeksforGeeks, Hackerrank, Leetcode, Codeforces. README file is updated with one execution of https://github.com/prateekshyap/DSA/blob/main/UpdateReadme.java
Install / Use
/learn @prateekshyap/DSAREADME
Topicwise-Solutions-To-Coding-Questions
Solutions to the algorithmic problems in LeetCode, GeeksForGeeks, Hackerrank, Interviewbit and Codeforces written in C++ and JAVA
What you can find in this repository
We have solved quite a number of problems from several topics. See the below table for further details.
How to contribute?
- Fork the repository
- Do the desired changes (add/delete/modify)
- Make a pull request
If you want to update the readme file as well, you have to install Java and Jsoup. Then you can run the UpdateReadme.java file to update the readme file.
When to contribute?
- If there is no solution to a problem in the main branch
- If your solution is asymptotically faster than the one in the main branch
- If your algorithm is of the same time complexity but with reduced code size (In this case, comment out the original solution and make a pull request with your solution.)
- If you have another method of solving the problem which is asymptotically slower than the original method (In this case, comment your solution in the main file and make a pull request.)
- If you want to update the UpdateReadme.java file
Format for solution files
- Paste the link for the question within comments.
- Paste the solution.
- Save with proper extension name.
Description of auto-updation of Readme file
UpdateReadme.java is the main file. It reads information (that are obtained online) from OnlineInfo.csv file. If you have updated the readme file with some online information without adding into csv file, then you need to run OnlineToCSV.java file to read that from readme and store in the csv file.
For difficulty level, csv file is already updated. For other online information columns you'll have to update it.
Algorithms
Number of Problems Solved (21-May-2023 11:22:31)
| Topic Name | Java | CPP | Python | | :--------: | :--------: | :--------: | :--------: | | Arrays | 123 | 75 | 0 | | BackTracking | 35 | 16 | 0 | | Bit-Magic | 32 | 23 | 0 | | Codeforces | 76 | 1 | 0 | | Concurrency | 6 | 0 | 0 | | Disjoint-Set | 6 | 1 | 0 | | Dynamic-Programming | 173 | 87 | 2 | | Graph | 93 | 50 | 1 | | Greedy | 60 | 19 | 0 | | Hashing | 75 | 23 | 0 | | Heap | 35 | 13 | 0 | | Linked-List | 67 | 42 | 0 | | Matrix | 56 | 27 | 0 | | Miscellaneous | 135 | 12 | 0 | | Queue | 12 | 6 | 0 | | Recursion | 14 | 13 | 0 | | Searching | 55 | 36 | 0 | | Segment-Tree | 4 | 0 | 0 | | Sorting | 19 | 7 | 0 | | Stack | 33 | 18 | 1 | | Strings | 118 | 47 | 0 | | Tree | 177 | 88 | 0 | | Trie | 18 | 13 | 0 | | Total | 1422 | 617 | 4 |
Reference
- C++
- JAVA
Arrays
| # |Title |Links |Solution |Difficulty |Time Complexity |Space Complexity | |-----|---------------- |---------------- |---------------- |---------------- |---------------- |---------------- | | 1 |Rearrange Array Alternately 1587115620|GFG |Java |Medium|O(n)|| | 2 |3sum With Multiplicity|LC |Java ||O(n<sup>2</sup>)|| | 3 |Arithmetic Sequences|BS |CPP Java ||O(n<sup>2</sup>)|| | 4 |Bulk Shift Letters|BS |CPP ||O(1)|| | 5 |Compressed Vector Product|BS |CPP ||O(1)|| | 6 |Dropped Sensor Metric|BS |CPP ||O(1)|| | 7 |K Distinct Window|BS |Java ||O(n)|| | 8 |Largest Sublist Sum|BS LC GFG |CPP Java |Medium|O(1)|| | 9 |Largest And Smallest Difference|BS |Java ||O(n)|| | 10 |Majority Vote|BS LC |Java ||O(n)|| | 11 |Maximum Absolute Value Of Sublist|BS LC |CPP Java ||O(1)|| | 12 |Number Of K Length Sublists With Average At Least Target|BS |Java ||O(n)|| | 13 |Rain Catcher|BS LC |Java ||O(n)|| | 14 |Remove Duplicates Occurring More Than Twice|BS LC |CPP Java ||O(1)|| | 15 |Set Split|BS |Java ||O(n<sup>2</sup>)|| | 16 |Split String With Same Distinct Counts|BS LC |Java ||O(n)|| | 17 |Submajority Vote|BS LC |Java ||O(n)|| | 18 |XOR Range Queries|BS |Java ||O(n)|| | 19 |Array Of Alternate Ve And Ve Nos1401|GFG |CPP Java |Easy|O(n<sup>2</sup>)|| | 20 |Bag Of Tokens|LC |Java ||O(n)|| | 21 |Best Time To Buy And Sell Stock|LC |CPP ||O(1)|| | 22 |Best Time To Buy And Sell Stock Ii|LC GFG |Java |Medium|O(n)|| | 23 |Binary Subarrays With Sum|LC |Java ||O(n)|| | 24 |Boats To Save People|LC |Java ||O(n)|| | 25 |Brick Wall|LC |Java ||O(n<sup>2</sup>)|| | 26 |Chocolate Distribution Problem3825|GFG |Java |Easy|O(n)|| | 27 |Common Elements1132|GFG |CPP [Java](./Arrays
Related Skills
node-connect
351.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
