Skip to content

Solving LeetCode's top 100+ classic problems using APL (A Programming Language) - one of the most esoteric and powerful array programming languages.

License

Notifications You must be signed in to change notification settings

wmh/leetcode-apl-solutions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

13 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง  LeetCode APL Solutions

License: MIT Language: APL Problems: 173 AI Generated

LeetCode problems solved in APL (A Programming Language)

โš ๏ธ AI-Generated Content Notice

This project was created with AI assistance. All APL solutions and explanations in this repository were generated using artificial intelligence. While efforts have been made to ensure code quality:

  • Solutions may contain errors or non-optimal approaches
  • Code has not been extensively tested in production APL interpreters
  • Explanations are based on code analysis and may not reflect APL best practices
  • This is primarily an educational/experimental project

Use at your own discretion. Contributions and corrections are welcome!


๐ŸŒ Languages: English | ็น้ซ”ไธญๆ–‡ | ็ฎ€ไฝ“ไธญๆ–‡ | ๆ—ฅๆœฌ่ชž | Espaรฑol | Deutsch | Franรงais

๐Ÿ“š Problems

View All 173 Problems

  • ๐ŸŸข Easy: 70+
  • ๐ŸŸก Medium: 50+
  • ๐Ÿ”ด Hard: 10+

๐Ÿš€ Quick Start

# Install APL
brew install gnu-apl  # macOS
apt install gnu-apl   # Linux

# Browse solutions
cd problems/001-two-sum
cat 001-two-sum.json

๐Ÿ“– Documentation

ReverseList โ† {โŒฝโต}

Complexity: Time O(n), Space O(1)


๐Ÿ“‚ Repository Structure

problems/
โ”œโ”€โ”€ 001-two-sum/
โ”‚   โ”œโ”€โ”€ README.md           # English
โ”‚   โ”œโ”€โ”€ README.zh-CN.md     # ็ฎ€ไฝ“ไธญๆ–‡
โ”‚   โ”œโ”€โ”€ README.zh-TW.md     # ็น้ซ”ไธญๆ–‡
โ”‚   โ”œโ”€โ”€ README.ja.md        # ๆ—ฅๆœฌ่ชž
โ”‚   โ”œโ”€โ”€ README.es.md        # Espaรฑol
โ”‚   โ”œโ”€โ”€ README.de.md        # Deutsch
โ”‚   โ””โ”€โ”€ README.fr.md        # Franรงais
โ”œโ”€โ”€ 136-single-number/
โ”‚   โ””โ”€โ”€ ... (7 language files)
โ””โ”€โ”€ 206-reverse-linked-list/
    โ””โ”€โ”€ ... (7 language files)

๐ŸŒ Multi-Language Support

This repository provides documentation in 7 languages:

Language README
๐Ÿ‡ฌ๐Ÿ‡ง English README.md
๐Ÿ‡น๐Ÿ‡ผ ็น้ซ”ไธญๆ–‡ README.zh-TW.md
๐Ÿ‡จ๐Ÿ‡ณ ็ฎ€ไฝ“ไธญๆ–‡ README.zh-CN.md
๐Ÿ‡ฏ๐Ÿ‡ต ๆ—ฅๆœฌ่ชž README.ja.md
๐Ÿ‡ช๐Ÿ‡ธ Espaรฑol README.es.md
๐Ÿ‡ฉ๐Ÿ‡ช Deutsch README.de.md
๐Ÿ‡ซ๐Ÿ‡ท Franรงais README.fr.md

Each problem file in the problems/ directory also includes descriptions and explanations in all 7 languages.

๐Ÿš€ Features

  • โœ… 100+ Classic Problems: Comprehensive coverage of LeetCode's most important problems
  • โœ… APL Solutions: Unique implementations using APL's powerful array operations
  • โœ… Detailed Explanations: Each solution includes complexity analysis and explanations
  • โœ… 7 Languages: Full documentation in English, ็นไธญ, ็ฎ€ไธญ, ๆ—ฅๆœฌ่ชž, Espaรฑol, Deutsch, Franรงais
  • โœ… Modular Structure: Each problem in its own JSON file for easy navigation
  • โœ… Educational Focus: Learn array programming through practical examples
  • โœ… Open Source: MIT licensed, contributions welcome

๐Ÿ“– Example Solutions

Problem 1: Two Sum

TwoSum โ† {
    โ โบ: target sum, โต: array
    indices โ† โธโบ=+/โˆ˜.,โจโต
    2โ†‘indices
}

โ Usage
target โ† 9
nums โ† 2 7 11 15
result โ† target TwoSum nums  โ Returns: 0 1

Explanation: Uses outer product โˆ˜. to generate all possible pair sums, then โธ to find matching indices.

  • Time Complexity: O(nยฒ)
  • Space Complexity: O(nยฒ)

Problem 136: Single Number

SingleNumber โ† {โ‰ /โต}

โ Usage
nums โ† 4 1 2 1 2
result โ† SingleNumber nums  โ Returns: 4

Explanation: XOR reduce - APL's โ‰  is XOR, / is reduce. Elegant one-liner leveraging XOR properties.

  • Time Complexity: O(n)
  • Space Complexity: O(1)

Problem 206: Reverse Linked List

ReverseList โ† {โŒฝโต}

โ Usage
list โ† 1 2 3 4 5
result โ† ReverseList list  โ Returns: 5 4 3 2 1

Explanation: โŒฝ is APL's reverse operator - the simplest possible solution!

  • Time Complexity: O(n)
  • Space Complexity: O(1)

๐Ÿ› ๏ธ Technology Stack

  • Language: APL (A Programming Language)
  • Documentation: Pure Markdown (Static)
  • Format: JSON data + Markdown READMEs
  • i18n: 7 languages (English, ็ฎ€ไธญ, ็นไธญ, ๆ—ฅๆœฌ่ชž, Espaรฑol, Deutsch, Franรงais)
  • Hosting: GitHub (static files)

๐Ÿ“‚ Project Structure

leetcode-apl-solutions/
โ”œโ”€โ”€ problems/                    # All problem solutions
โ”‚   โ”œโ”€โ”€ 001-two-sum/            # Each problem in its own directory
โ”‚   โ”‚   โ”œโ”€โ”€ README.md           # 7 language versions
โ”‚   โ”‚   โ”œโ”€โ”€ README.zh-CN.md
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ 136-single-number/
โ”‚   โ”œโ”€โ”€ 206-reverse-linked-list/
โ”‚   โ””โ”€โ”€ index.json              # Problem metadata
โ”œโ”€โ”€ PROBLEMS_INDEX.md           # Complete problem list (7 languages)
โ”œโ”€โ”€ PROBLEMS_INDEX.zh-CN.md
โ”œโ”€โ”€ README.md                   # Main documentation (7 languages)
โ”œโ”€โ”€ README.zh-CN.md
โ””โ”€โ”€ generate_static_readmes.py  # Generator script

๐Ÿ’ป How to Use

๐ŸŒ Browse on GitHub

Simply browse this repository on GitHub! No server needed - everything is static Markdown files.

  1. Start here: PROBLEMS_INDEX.md - Complete list of all problems
  2. Click any problem to view its full solution with explanation
  3. Switch languages using the navigation bar at the top of each page

๐Ÿ“ฅ Clone Locally

git clone https://github.com/wmh/leetcode-apl-solutions.git
cd leetcode-apl-solutions

# View complete problem list
cat PROBLEMS_INDEX.md

# Browse a specific problem
cat problems/001-two-sum/README.md

# View in Chinese
cat problems/001-two-sum/README.zh-CN.md

๐Ÿ”ง Try the APL Solutions

To actually run the APL code, you'll need an APL interpreter:

  1. Online (easiest): Visit TryAPL.org
  2. Dyalog APL: Download from dyalog.com
  3. GNU APL:
    • Linux: apt install gnu-apl
    • macOS: brew install gnu-apl

๐Ÿ”„ Generate More Problems

Use the included generator script to create new problem READMEs:

# Add your problem data to problems/*.json
# Then regenerate all READMEs
python3 generate_static_readmes.py

๐Ÿค Contributing

Contributions are welcome! Here's how you can help:

  1. Add More Problems: Implement additional LeetCode problems in APL
  2. Improve Solutions: Optimize existing APL solutions
  3. Fix Bugs: Report and fix any issues you find
  4. Translations: Help improve language translations
  5. Documentation: Enhance problem explanations

๐Ÿ“˜ Contribution Guide

See HOW_TO_ADD_PROBLEMS.md for detailed instructions on adding new problems.

Quick steps:

  1. Create a JSON file in problems/ with your solution
  2. Run python3 generate_static_readmes.py
  3. Commit and push your changes

Contribution Steps

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

๐Ÿ“š Resources

Learn APL

LeetCode

๐Ÿ“œ License

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

๐Ÿ™ Acknowledgments

  • Kenneth E. Iverson - Creator of APL
  • LeetCode - For providing excellent algorithmic problems
  • Dyalog Ltd - For maintaining and developing APL
  • APL Community - For keeping this beautiful language alive

๐Ÿ“ง Contact

โญ Star History

If you find this project helpful, please consider giving it a star! โญ


Made with โค๏ธ and lots of โต, โบ, โŒฝ, and โˆ‡

"APL is a mistake, carried through to perfection. It is the language of the future for the programming techniques of the past: it creates a new generation of coding bums." - Edsger W. Dijkstra

"APL is like a perfect diamond: flawless, beautifully symmetrical, but you can't do anything with it." - Unknown

Despite the criticisms, APL remains one of the most elegant and powerful languages for array manipulation! ๐ŸŽฏ

About

Solving LeetCode's top 100+ classic problems using APL (A Programming Language) - one of the most esoteric and powerful array programming languages.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published