Skip to content

ChanMeng666/juejin-algorithm-practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Algorithm Practice

A collection of 81 algorithm problems with Python solutions, originally from the ByteDance MarsCode Youth Training Camp. Each problem includes a detailed description, solution approach, complexity analysis, and tested implementation.

Python 3.6+ Problems License: MIT

Getting Started

git clone https://github.com/ChanMeng666/juejin-algorithm-practice.git
cd juejin-algorithm-practice

# Run any solution
python problems/001-find-unique-number/solution.py

# Read the problem description
cat problems/001-find-unique-number/README.md

Structure

problems/
  001-find-unique-number/
    README.md       # Problem description, examples, and solution explanation
    solution.py     # Python solution with test cases
  002-optimal-food-supply-strategy/
    ...

Topics Covered

Topic Examples
Arrays & Strings Majority element, string transformation, pattern matching
Dynamic Programming Edit distance, stock trading, subarray optimization
Greedy Algorithms Optimal refueling, food supply, menu selection
Math & Number Theory Combination sum, percentile calculation, probability
Binary Search Monster sequence, arena escape
Graph & Tree Flight routes, virus propagation, tree traversal
Bit Manipulation Find unique number, XOR operations
Sorting & Searching Top-K elements, multi-criteria sorting
Simulation Board games, card games, shooting scores
Encoding & Decoding Base32, binary strings, RGB conversion

Problem Index

# Problem Topics
001 Find Unique Number Bit Manipulation, Arrays
002 Optimal Food Supply Strategy Greedy, Arrays
003 Number Thousands Separator Strings, Formatting
004 Combination Sum Backtracking, Recursion
005 Texas Hold'em Full House Sorting, Simulation
006 Longest Defeatable Monster Sequence Greedy, Sorting
007 Wildcard Matching DP, Strings
008 Majority Element Arrays, Voting Algorithm
009 Supermarket Product Arrangement Greedy, Sorting
010 Token Card Breakeven Math, Simulation
011 Best Sightseeing Pair DP, Arrays
012 Max UCC Substring Count Strings, Counting
013 Construct Pattern Array Arrays, Construction
014 Construct Minimum Sum Array Greedy, Arrays
015 String Prefix Transformation Strings, Simulation
016 Largest Rectangle Area Stack, Arrays
017 Array Transformation Arrays, Math
018 Alternating Uphill Downhill Path DP, Arrays
019 Lexicographically Smallest String Greedy, Strings
020 Tournament Pairing Simulation, Math
021 Circular Array Max Contribution Arrays, Prefix Sum
022 Minimum String Operations Strings, Greedy
023 Stone Jumping Game DP, Game Theory
024 Special Playlist Order Arrays, Simulation
025 DNA Sequence Edit Distance DP, Strings
026 Digit Insertion Greedy, Strings
027 Hero Training DP, Greedy
028 Arena Escape Binary Search, Greedy
029 String Conversion Strings, Counting
030 Max "ku" Count in String Strings, Greedy
031 Count Distinct Integers in String Strings, Parsing
032 Digit Sum Game Math, Game Theory
033 Card Flip Sum Greedy, Arrays
034 Third Largest Number Arrays, Sorting
035 Inverted Index Intersection Arrays, Two Pointers
036 Optimal Menu Selection DP, Knapsack
037 Smallest Non-Palindrome Strings, Greedy
038 Travel Optimal Resupply Greedy, Simulation
039 AB Experiment Minimum Steps BFS, Strings
040 Circular DNA Minimum Representation Strings, Comparison
041 Balanced ASDF String Strings, Sliding Window
042 Tree Gift Decoration Trees, DFS
043 Restore Original String Strings, Deque
044 Shooting Score Calculator Simulation, Arrays
045 Digit Removal Greedy, Stack
046 Large Number Addition Math, Strings
047 Perfect Even Count Math, Counting
048 String Replacement Strings, Simulation
049 Multi-Criteria Sorting Sorting, Custom Comparator
050 Optimal Refueling Strategy Greedy, Simulation
051 Reconstruct Array from Pair Sums Math, Construction
052 Basic Calculator Stack, Parsing
053 Course Score Combinations DP, Backtracking
054 Decode Numbers to String DP, Strings
055 Binary String Sum to Decimal Math, Binary
056 Cat Fish Distribution Greedy, Math
057 Red Packet Three-Way Split Math, Combinatorics
058 Base32 Encode/Decode Encoding, Bit Manipulation
059 Binary String Flip Optimization DP, Strings
060 RGB to Hex Integer Math, Bit Manipulation
061 Optimal Flight Route Graph, DP
062 Virus Propagation Graph, BFS
063 Percentile Calculation Math, Statistics
064 Hero Battle Sequence Greedy, Sorting
065 Needle Rain Shooting Geometry, Simulation
066 Dessert Preference Matching Sorting, Two Pointers
067 Number Guessing Probability Math, Probability
068 Journey Water Supply Greedy, Simulation
069 Top K Frequent Elements Hash Map, Sorting
070 Dot Counter Arrays, Interval
071 Cake Factory Optimization DP, Optimization
072 Domino Tiling DP, Math
073 SQL Editor Autocomplete Trie, Strings
074 Plate Stacking Greedy, Stack
075 Binary Tree Node Count Trees, Recursion
076 Group Familiarity Optimization Graph, DP
077 Quality Chapter Selection DP, Arrays
078 Board Game Piece Grouping Math, Counting
079 Max Subarray Sum with Flip DP, Arrays
080 Stock Trading with Cooldown DP, State Machine
081 DNA Edit Distance DP, Strings

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/improvement)
  3. Commit your changes (git commit -m 'Add improvement')
  4. Push to the branch (git push origin feature/improvement)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Chan Meng - GitHub

Releases

No releases published

Sponsor this project

Packages

 
 
 

Contributors

Languages