Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Pull detail msg for runtime error #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gynet opened this issue Nov 15, 2016 · 6 comments
Closed

Pull detail msg for runtime error #14

gynet opened this issue Nov 15, 2016 · 6 comments

Comments

@gynet
Copy link

gynet commented Nov 15, 2016

When a submission got runtime error, there is no detail message return to the console. It would nice if leetcode-cli can pull the detail error msg.

@skygragon
Copy link
Owner

could you give a user case that I can dig into?

@gynet
Copy link
Author

gynet commented Dec 6, 2016

Use case:

https://leetcode.com/problems/longest-increasing-subsequence/

If you test with following code:

public class Solution {
public int lengthOfLIS(int[] nums) {
int [] dp = new int [nums.length+1];
if (nums.length == 0){
return 0;
}
int size = 1;
dp[1] = nums[0];
for (int i = 0; i < nums.length; i++){
int k = Arrays.binarySearch(dp, 1, i, nums[i]);
if (k == size + 1){
size++;
}
if (k < 0){
k = -( k + 1);
}
dp[k] = nums[i];
}
return size;
}

@gynet
Copy link
Author

gynet commented Dec 8, 2016

with latest build, still did not see runtime error in cli, so currently I have to login to web for debugging.

Test case:

leetcode test zigzag-conversion.java -t '[3,9,20,null,null,15,7]'

Actual Output:

Your
✘ Runtime Error
✘ runtime: N/A
✘ output:

Expected
✘ Runtime Error
✘ runtime: N/A
✘ output:

Excepted output
Line 21: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0


public class Solution {
public List zigzagLevelOrder(TreeNode root) {
List res = new ArrayList();
dfs(root, 0, res);
return res;
}

public void dfs (TreeNode node, Integer level, List<List> res ){
if (node == null){
return;
}
List levelNodes = res.get(level);
if (res.get(level) == null){
levelNodes = new ArrayList();
res.add(levelNodes);
}

//right; left
if (level % 2 == 1){
    levelNodes.add(0, node.val);
}
else {
    levelNodes.add(node.val);
}
dfs(node.left, level+1, res);
dfs(node.right, level+1, res);

}
}

@skygragon
Copy link
Owner

hmm..this source code should aim at binary-tree-zigzag-level-order-traversal.java, not zigzag-conversion.java, right?

Following is what I run using this code:

⭠master leetcode-cli# leetcode test binary-tree-zigzag-level-order-traversal.java -t '[3,9,20,null,null,15,7]'

Input data:
[3,9,20,null,null,15,7]

Your
    ✘ Runtime Error
    ✘ runtime: N/A
    ✘ output:
    ✘ error: Line 12: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0


Expected
    ✔ runtime: 0 ms
    ✔ answer: [[3],[20,9],[15,7]]
    ✔ output:

Do you try to update the global version of leetcode-cli on your machine? something like:

leetcode-cli$ git pull --rebase original master
leetcode-cli$ sudo npm install -g .

@gynet
Copy link
Author

gynet commented Dec 8, 2016

Oh, your are right, my bad, linked to a wrong source file, currently it's working as excepted. Sorry for bring the confusion.

@gynet
Copy link
Author

gynet commented Dec 8, 2016

Please close it

tainenko pushed a commit to tainenko/leetcode-cli that referenced this issue Sep 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants