![](https://img-blog.csdnimg.cn/20210804110855392.jpg?x-oss-process=image/resize,m_fixed,h_224,w_224)
leetcode&牛客
leetcode
牛客
善逸啊
贡献榜
1-200:45000
200-400:40000
400-600:35000
无排名:30000
展开
-
leetcode题库☞ 600. 不含连续1的非负整数
class Solution { public int findIntegers(int n) { int k = 0; for (int i = n; i >= 0; i--) { String binaryString = Integer.toBinaryString(i); char[] chars = binaryString.toCharArray(); boolean flag.原创 2021-09-11 10:49:44 · 163 阅读 · 0 评论 -
leetcode题库☞ 233. 数字 1 的个数
贴一段比较好的方式:代码越简单,思维越复杂……可以自己画个函数图class Solution { public int countDigitOne(int n) { int sum = 0; for (int i = 1; i <= n; i *= 10) { /* n/i*10 n%(i*10)=x x < i = 0 x < 2i =.原创 2021-08-17 16:33:48 · 211 阅读 · 0 评论 -
leetcode题库☞ 313. 超级丑数
public int nthSuperUglyNumber(int n, int[] primes) { //int[] all = {1, 2, 4, 7, 8, 13, 14, 16, 19, 26, 28, 32}; Set<Long> seen = new HashSet<>(); Queue<Long> heap = new PriorityQueue<>(); seen.ad...原创 2021-08-09 20:36:52 · 172 阅读 · 0 评论 -
leetcode题库☞ 226.经典之翻转二叉树
经典处刑Max Howell……class Solution { public TreeNode invertTree(TreeNode root) { if (root == null) { return null; } TreeNode left = invertTree(root.left); TreeNode right = invertTree(root.right); root.l原创 2021-06-04 16:22:12 · 96 阅读 · 0 评论 -
leetcode题库☞ 5. 最长回文子串
题干题解方法一:动态规划public class Solution { public String longestPalindrome(String s) { int len = s.length(); if (len < 2) { return s; } int maxLen = 1; int begin = 0; // dp[i][j] 表示 s[i..j]原创 2021-05-19 12:22:05 · 87 阅读 · 0 评论 -
leetcode题库☞ 3. 无重复字符的最长子串
题干:题解:class Solution { public int lengthOfLongestSubstring(String s) { // 记录字符上一次出现的位置 int[] last = new int[128]; for(int i = 0; i < 128; i++) { last[i] = -1; } int n = s.length(); int r原创 2021-05-16 23:10:05 · 84 阅读 · 0 评论