Skip to content

woogi-kang/leetcode-dart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode Solutions in Dart

This repository contains solutions to LeetCode problems implemented in Dart, with a focus on clean code, performance tracking, and comprehensive documentation.

🚀 Getting Started

Prerequisites

  • Dart SDK >=3.1.0
  • Git

Setup

  1. Clone the repository
git clone https://github.com/yourusername/leetcode-dart.git
cd leetcode-dart
  1. Install dependencies
dart pub get
  1. Run a solution with performance metrics
dart run src/two_sum.dart --enable-vm-service

Adding New Solutions

  1. Create a new file in the appropriate category folder:
mkdir -p src/category_name
touch src/category_name/problem_name.dart
  1. Use the standard header template:
/ ==========================================
Problem Number. Problem Name
==========================================
Category: Your Categories
Difficulty: Easy/Medium/Hard
Problem Description
==========================================
Copy the problem description here...
Examples
==========================================
Example 1:
Input: ...
Output: ...
Constraints
==========================================
List constraints...
Approach
==========================================
Explain your approach...
Time Complexity: O(...)
Space Complexity: O(...)
/
  1. Implement your solution with the Utils class:
import '../utils.dart';

class Solution {
// Your solution here
}

void main() {
    final solution = Solution();
    
    Utils.runTimer('Problem Name', () {
        return solution.methodName(input);
    });
}

📊 Performance Tracking

The Utils class provides performance metrics for each solution:

  • Execution time
  • Memory usage
  • Result validation

Run solutions with the VM service flag to get memory metrics:

dart run src/your_solution.dart --enable-vm-service

🗂️ Project Structure

leetcode-dart/
├── src/                # Solutions by category
│   ├── arrays/        # Array-based problems
│   ├── bfs/           # Breadth-First Search
│   ├── dfs/           # Depth-First Search
│   ├── dp/            # Dynamic Programming
│   ├── sliding_window/# Sliding Window
│   ├── two_pointers/  # Two Pointers
│   └── utils.dart     # Performance tracking utilities
├── test/              # Test cases (coming soon)
└── README.md          # Documentation

📝 Contributing

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

🔍 Solutions Index

Problem File Difficulty Tags
1. Two Sum two_sum.dart Easy Hash Table, Array
3. Longest Substring Without Repeating Characters longest_substring.dart Medium Sliding Window, Hash Set
5. Longest Palindromic Substring longest_palindrome.dart Medium Dynamic Programming, String
11. Container With Most Water container_water.dart Medium Two Pointers, Array
13. Roman to Integer roman_to_int.dart Easy Hash Table, Math, String
17. Letter Combinations of a Phone Number letter_combinations.dart Medium Backtracking, String
36. Valid Sudoku valid_sudoku.dart Medium Array, Hash Set, Matrix
62. Unique Paths unique_paths.dart Medium Dynamic Programming
70. Climbing Stairs climbing_stairs.dart Easy Dynamic Programming
121. Best Time to Buy and Sell Stock buy_sell_stock.dart Easy Two Pointers, DP
122. Best Time to Buy and Sell Stock II buy_sell_stock2.dart Medium Arrays, Greedy
300. Longest Increasing Subsequence lis.dart Medium Dynamic Programming
309. Best Time to Buy and Sell Stock with Cooldown buy_sell_cooldown.dart Medium Dynamic Programming
322. Coin Change coin_change.dart Medium Dynamic Programming
347. Top K Frequent Elements top_k_frequent.dart Medium Hash Table, Heap
647. Palindromic Substrings palindromic_substr.dart Medium Dynamic Programming, String
695. Max Area of Island max_area_island.dart Medium DFS, Matrix
746. Min Cost Climbing Stairs min_cost_stairs.dart Easy Dynamic Programming
994. Rotting Oranges rotten_oranges.dart Medium BFS, Matrix

📄 License

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

🤝 Contributing

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages