Git Product home page Git Product logo

leetcode's People

Contributors

lzl124631x avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leetcode's Issues

[1985] Comments on The Choice of Sorting

Based on the LCP string comparison algorithm you provided, it should be more clear to use a selection algorithm instead of the sorting on the whole array.

string kthLargestNumber(vector<string>& nums, int k) {
    nth_element(nums.begin(), nums.begin() + k - 1, nums.end(), [](auto& a, auto& b) {
        // return true if a is lexicographical larger than b.
        int N = a.size(), M = b.size();
        if (N > M) return true;
        if (N < M) return false;
        for (int i = 0; i < N; ++i) {
            if (a[i] != b[i])
                return a[i] > b[i];
        }
        return false;
    });
    return nums[k-1];    
}

Time/Space complexity clarifications

First of all, thanks so much for this repo as a very helpful reference. I have a question regarding one of time/space complexity of the code: https://github.com/lzl124631x/LeetCode/tree/master/leetcode/505.%20The%20Maze%20II

Are you sure the Time is O(mn)? Looks like from the discussion and solution tab the best they can achieve with BFS/DFS is O(mnmax(m,n)). Even with PriorityQueue the best achieved is O(mnlog(m*n)). Reference:
https://leetcode.com/problems/the-maze-ii/solution/
https://leetcode.com/problems/the-maze-ii/discuss/?currentPage=1&orderBy=most_votes&query=

Test cases for testcase.js

Input: 5
Output: True
Input: root = [3,5,1,6,2,0,8,null,null,7,4], target = 5, K = 2

Output: [7,4,1]
Input: 
board = [
  ['o','a','a','n'],
  ['e','t','a','e'],
  ['i','h','k','r'],
  ['i','f','l','v']
]
words = ["oath","pea","eat","rain"]
Input
["CustomStack","push","push","pop","push","push","push","increment","increment","pop","pop","pop","pop"]
[[3],[1],[2],[],[2],[3],[4],[5,100],[2,100],[],[],[],[]]
Input: 
[[1,1,0],
 [1,1,0],
 [0,0,1]]
Input: S = "rabbbit", T = "rabbit"
Output: 3
Explanation:

As shown below, there are 3 ways you can generate "rabbit" from S.
(The caret symbol ^ means the chosen letters)

rabbbit
^^^^ ^^
rabbbit
^^ ^^^^
rabbbit
^^^ ^^^

Leetcode 704 will fail, need to check boundary

class Solution {
public:
int search(vector& A, int target) {
int L = 0, R = A.size();
while (L <= R) {
int M = (L + R) / 2;
if (A[M] == target) return M;
if (A[M] < target && A.size() != M + 1) L = M + 1;
else R = M - 1;
}
return -1;
}
};

quiz.bookmark.js

Since you already have a script to extract solution answer.bookmark.js, I think it will be convenient to just extract the solution and paste it in this script.

[50] Unrolling A Recursion Termination Condition

The original solution is perfect. Seems to be faster if pulling the condition of the negative outside.

double pow(double x, int n) {
    return n < 0 ? 1/pow(x, (long)-1*n) : pow(x, (long)n);
}
double __pow(double x, long n) {
    if (n == 0) return 1;
    if (n == 1) return x;
    if (n == 2) return x * x;
    if(n % 2)
        return __pow(__pow(x, n / 2), 2);
    else
	return __pow(__pow(x, n / 2), 2) * x;
}

1654 is "Page not found"

1654 Minimum Jumps to Reach Home Medium Solution

This one gives 404 Page Not Found. I wonder if you have done it and the page got corrupted.

How do you automate your local debug.

From your repo files, I assume you are not using vscode extensions for leetcode local debug as you write a bunch of scripts helping to automate the process. But I cannot find the html file running those js scripts which I find very useful for scraping leetcode api data. Can you shed some light one your workflow? Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.