need to add more test cases?


  • 0
    I

    Hi,

    Can we add some more test cases?
    say: [0,1,2,3,4,5,6,12]

    Below attached code should not pass, but it got AC.

    class Solution {
    public:
        bool canCross(vector<int>& stones) {
            if (stones[1] != 1) {
                return false;
            }
    
            unordered_map<int, unordered_set<int>> last_jump_units;
            for (const auto& s: stones) {
                last_jump_units.emplace(s, {unordered_set<int>()});
            }
            last_jump_units[1].emplace(1);
    
            for (int i = 0; i + 1 < stones.size(); ++i) {
                for (const auto& j : last_jump_units[stones[i]]) {
                    for (const auto& k : {j - 1, j, j + 1}) {
                        if (k > 0 && last_jump_units.count(stones[i] + k)) {
                            last_jump_units[stones[i] + k].emplace(k);
                        }
                    }
                }
            }
    
            return !last_jump_units[stones.back()].empty();
        }
    };
    

    Your input

    [0,1,2,3,4,5,6,12]

    Your answer :true
    Expected answer :false

    Submission Result: Accepted


  • 0

    @iroot900 Thanks, I have just added your test case.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.