摘要:
这道题没有想法。。。。 解法一:暴力解法 public int rangeBitwiseAnd(int m, int n) { int res = m; for (int i = m + 1; i <= n; i++) { res &= i; } return res; } 作者:windliang 阅读全文
摘要:
首先想到的是异或,会出现一个与不为零得值 可以使用暴力查找或者快排,快排复杂度是o(nlogn) 或者是使用hash表,但是会占用多余得空间复杂度 异或: class Solution { public int singleNumber(int[] nums) { int ans=nums[0]; 阅读全文
摘要:
方法一:;来自大佬 public ListNode reverseKGroup(ListNode head, int k) { ListNode dummy = new ListNode(0); dummy.next = head; ListNode pre = dummy; ListNode en 阅读全文
摘要:
import java.util.Stack; public class MinStack { // 数据栈 private Stack<Integer> data; // 辅助栈 private Stack<Integer> helper; /** * initialize your data s 阅读全文
摘要:
我都不好意思写 我没想出来二分法。。。。 方法一:二分法 public class Solution { public int mySqrt(int x) { long left = 0; long right = Integer.MAX_VALUE; while (left < right) { 阅读全文