You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will autom…
Leetcode之二分法专题-275. H指数 II(H-Index II) 给定一位研究者论文被引用次数的数组(被引用次数是非负整数),数组已经按照升序排列.编写一个方法,计算出研究者的 h 指数. h 指数的定义: “h 代表“高引用次数”(high citations),一名科研人员的 h 指数是指他(她)的 (N 篇论文中)至多有 h 篇论文分别被引用了至少 h 次.(其余的 N - h 篇论文每篇被引用次数不多于 h 次.)" 示例: 输入: citations = [0,1,3,5,…
Leetcode之回溯法专题-52. N皇后 II(N-Queens II) 与51题的代码80%一样,只不过52要求解的数量,51求具体解,点击进入51 class Solution { int ans = 0; public int totalNQueens(int n) { char mp[][] = new char[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { mp[i][j] = '.'; }…