NO.2 简单 (176. 第二高的薪水) leetcode-cn.com/problem # 将第一高的工资筛选掉,再次用MAX就可以取到第二高的工资了。 select max(Salary) as SecondHighestSalary from Employee where Salary <> (select max(Salary) from Employee) NO.3
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.
r=-1,len(nums)whiler-l>1:m=(l+r)//2ifnums[m]<target:l=melifnums[m]>target:r=melse:returnm# Exit: r = l + 1, no element between l and rreturn-1# Time Complexity: O(log(N))# Space Complexity: O(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 进阶:你可以运用递归和迭代两种方法解决这个问题吗?
数字n代表生成括号的对数,请你设计一个函数,用于能够生成所有可能的并且有效的括号组合。 示例1: 输入:n = 3输出:["((()))","(()())","(())()","()(())","()()()"] 示例2: 输入:n = 1输出:["()"] 提示: 1 <= n <= 8 ...
53. 最大子数组和 - 给你一个整数数组 nums ,请你找出一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。 子数组 是数组中的一个连续部分。 示例 1: 输入:nums = [-2,1,-3,4,-1,2,1,-5,4] 输出:6 解释:连续子数组 [4,-1,2,1] 的和最大,为
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 classSolution { public: vector<vector<int>> threeSum(vector<int>& nums) { sort(nums.begin(), nums.end()); vector<vector<int> > validSet; ...
挣扎了一段时间,就去讨论区看解答(https://leetcode.com/problems/strong-password-checker/discuss/91003/O(n%29-java-solution-by-analyzing-changes-allowed-to-fix-each-problem)去了: 代码语言:javascript 代码运行次数:0 运行 复制 class Solution { public int strongPasswordChecker(String s) { int res...
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){ ...
51.N-Queens Hard The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. Each solution contains a distinct board configuration of the n-queens ...