Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
// Solution 1: This is a very challenging problem, maybe because it looked like one and proved exactly to be one. It's among the last few problem I solved on LeetCode. It took me hours to think it through and another 1 or 2 to write an acceptable version of code. A rough idea w...
53. 最大子数组和 - 给你一个整数数组 nums ,请你找出一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。 子数组 是数组中的一个连续部分。 示例 1: 输入:nums = [-2,1,-3,4,-1,2,1,-5,4] 输出:6 解释:连续子数组 [4,-1,2,1] 的和最大,为
给你一个二叉树的根节点root, 检查它是否轴对称。 示例1: 输入:root = [1,2,2,3,4,4,3]输出:true 示例2: 输入:root = [1,2,2,null,3,null,3]输出:false 提示: 树中节点数目在范围[1, 1000]内 -100 <= Node.val <= 100 进阶:你可以运用递归和迭代两种方法解决这个问题吗?
217_Contains_Duplicate Leet code problem 217 Jan 11, 2023 21_Merge_linked_lists Solve leetcode question 21 Mar 15, 2023 22_Generate_Parenthesis.java Improve leetcode question 22 Jan 13, 2023 238_Product_of_Array_Except_Self Solved leetcode question 238 ...
365 Water and Jug Problem Algorithms Medium 363 Max Sum of Rectangle No Larger Than K Algorithms Medium 357 Count Numbers with Unique Digits Algorithms Medium 355 Design Twitter design-twitter Algorithms Hard 354 Russian Doll Envelopes Algorithms Hard 352 Data Stream as Disjoint Intervals Algorithms Ha...
实现pow(x,n),即计算x的整数n次幂函数(即,xn)。 示例1: 输入:x = 2.00000, n = 10输出:1024.00000 示例2: 输入:x = 2.10000, n = 3输出:9.26100 示例3: 输入:x = 2.00000, n = -2输出:0.25000解释:2-2= 1/22= 1/4 = 0.25 提示: ...
This problem was inspired by this original tweet by Max Howell: Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so fuck off. 【解答】这个段子已经在互联网上广为流传了,实际事情的背景我们不得而知。不过如果真是...
testHead=testHead.next; } }if(!valid){break; }if(pre ==null){ pre=testHead; ret=pre; }else{ pre.next=testHead; } ListNode oldPre=current; ListNode next=current.next; current.next=testHead.next; pre=current; current=next;for(inti = 1; i < k; ++i){ ...
另一个union-find, 用hashmap的:lintcode.com/en/problem 83. Gray Code.java Level: Medium 题目蛋疼,目前只接受一种结果。 BackTracking + DFS:Recursive helper里每次flip一个 自己/左边/右边. Flip过后还要恢复原样.遍历所有. 曾用法(未仔细验证):基本想法就是从一个点开始往一个方向走,每次flip一个bit,...