整理出了90道leetcode题目,均能通过OJ测试。大部分题目都给出了多种解法并有说明。之所以说是整理,是因为很多题目的代码不是自己写的。有些我觉得思路差不多,代码应该 ...
昨天晚上发现的新题,搜一下类似解法,然后今天早上研究出来了,应该会有更好地方法,看到再更新吧。我把我借鉴别人修改后的方法放这。[code]public int maxProduct(int[] ...
Hi I saw so many versions of solutions in C++ for Leetcode. It's hard to pick one most helpful, but spent too much time to look into each one. Can anyone please ...
https://oj.leetcode.com/problems/valid-number/今晚编了一编。编程不好,努力提高中。系统说:Last executed input: " "我咋感觉我的代码挺对的 ...
Find Minimum in Rotated Sorted Array II. 就是Find Minimum in Rotated Sorted Array中有重复的数怎么办。https://oj.leetcode.com/problems ... ed-sorted-array-ii/ ...
本人编程小白,今天试了第一个题 (Find Minimum in Rotated Sorted Array)就蛋疼了。我编的程序在自己的codeblock下能跑对数,在网上测出的答案怎么和我私下跑的结果不一 ...
就是那道要输出所有不同的BST的题: Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your ...
目前的题目都是150题,求指点
测试数组是{4,5,6,7,0,1,2},想查找8让函数返回-1,但是老显示time out咋回事啊?[code]public class SearchinRotatedSortedArray { public static int search(in ...
感觉一般情况下,能不直接给二叉树/链表改值的,都不会直接改值这道题要求用O(1)空间复杂度,然后我只能想到找到两个对调节点以后改值了。看了一下我一直参考的“正确 ...
才开始新学java,打算同时用leetcode练手,结果第一题就有问题了。楼主代码如下,在本地eclipse上运行没问题,但是把solution类放到leetcode上就报错了,而且报的错莫名其 ...
用dfs写的,debug了半天,找不出问题,找版上大牛求助![code]#include #include using namespace std;struct UndirectedGraphNode { int label; vector neigh ...
不知道这道题大家都是用什么方法做的~之前的想法是把所有的可能行楼罗列出来~然后写出来一个大的if-else if-else的block~就可以了~这样也能accept~但是有点繁琐~ ...
请教大家一个问题~在leetcode merge intervals 这道题里面, 自己写的程序看了半天都没有问题~但是在OJ面前总是出现runtime error~最后找到了毛病~是出在了这个部位: ...
Leetcode中4sum的题目是这样的:Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadr ...
因为面试的时候是在白纸上写的,平时刷题都是在IDE里面,导致面试的时候好不习惯。大家都是直接在上面打?
如题...
不明白这样的运行结果:leetcode的运行结果:Line 12: expected ';' at end of member declaration。
#include using namespace std;class Solution {public: void merge(int A[], int m, int B[], int n) { int i = m-1; int j = n-1; ...
这道题是吧输入的一句话反过来。但是就是找不到我的代码的错误在哪里。leetcode上说runtime error。告诉我再输入“a”的时候出了问题。但是我在自己电脑上也试过了,没问题 ...