在做Permutations这题时,遇到了一个小问题,想不明白发出来问问。。code:public class Solution { ArrayList res = new ArrayList(); ArrayList item = ...
LeetCode今天更新了一道新题,难度Easy,我做完之后在上面分享了一种解法,很好理解,和答案的思路不同。主要思路就是跳过较长的List前面的nodes,从长度相等的地方开 ...
题目 :Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The functi ...
我做到032 Longest Valid Parentheses这题的时候怎么输出的结果和OJ的不一样,我在电脑上用g++ 032.cpp -std=c++11 编译完了运行,结果是2但是提交leetcode 的OJ上面的时 ...
leetcode题目如下:Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a l ...
Combination sum 迭代怎么写,谁有代码给个链接看看?补充内容 (2014-11-3 23:55):谢谢各位的回复,这题用recursion比较简单而且直观。我现在是想问下有没有iteration ...
Depth-first:pre-order, in-order, post-orderPre-order:preorder(node) if node == null then return visit(node) preorder(node.left) preord ...
Compare two version numbers version1 and version1.If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0.You may assume that ...
這題大家應該都聽到泛濫了吧...好多家大公司都問過這題.... 我找到一個挺簡潔的solution 在這裡: http://www.programcreek.com/2012/12/leetcode-median-of-two-sorted ...
开个贴子自我督促一下哈~顺便分享一下自己的思路,欢迎讨论~2楼:Anagrams3楼:Wildcard Matching 4-5楼:Jump Game II 6楼:Flatten Binary Tree to Linked L ...
非CS专业小白今日开始学习动态规划,遇到了这一题:https://oj.leetcode.com/problems/wildcard-matching/辛辛苦苦琢磨了三小时写出了代码,一跑却是Submission Resul ...
lz不是第一次碰到了,一模一样的代码,oj给的答案和我本地跑的结果是一样的,但是和oj跑的结果就是不一样……这个不叫debug好嘛,这叫做坑啊………………和其他的oj比一比 ...
看到有同学在地里发帖说看不了。 我这里发出来。话说45块确实有点贵。 我是当时15块买的。 过2天就涨到了45块了。 10道题,一道4块。。
记录刷了多少,今天看了1-4,有些没看懂
例如4sum, O(n^3)的解法 C++和JAVA都能过, python就过不了,只能用O(n^2)的hashmap
这里我觉得难的地方在于对题目的理解,尤其是对于我这种没做过底层,embedded 之类的,首先说read4这个function[/backcolor]官方给出的是 int read4(char *buf); 注意做 ...
http://www.ninechapter.com/solutions/remove-duplicates-from-sorted-list-ii/#java
题目是:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((() ...
原题是这样的,Given a binary tree, return the preorder traversal of its nodes' values.我的solution是这样的,我不能理解的是每次这个method都要create a new arr ...
请问大家 做题时候的corner case怎样才能考虑比较全面呢?比如Linked List问题中NULL,单一node,等等。比如LeetCode里面 Remove Nth node from the end这道题。特殊情 ...