随笔分类 - LeetCode
1
摘要:上面的代码转载自:K路归并问题小结 在LeetCode 23中是合并k路链表 23. Merge k Sorted Lists 自己的代码如下,采用的是优先级队列
阅读全文
摘要:median-of-two-sorted-arrays https://blog.csdn.net/yutianzuijin/article/details/11499917
阅读全文
摘要:转载自http://hovertree.com/h/bjaf/pk4rwg78.htm 1.list中添加,获取,删除元素; 添加方法是:.add(e); 获取方法是:.get(index); 删除方法是: .remove(index);按照索引删除; .remove(Object o); 按照元素
阅读全文
摘要:remove-nth-node-from-end-of-list 自己的方法,很笨 这个居然有快慢指针的方法,厉害了,贴上方法!!!
阅读全文
摘要:remove-duplicates-from-sorted-list reverse-nodes-in-k-group 同一类问题swap-nodes-in-pairs remove-nth-node-from-end-of-list
阅读全文
摘要:Prime Number of Set Bits in Binary Representation 求某个数是否是素数(一个数只有两个因数1和它本身,则是素数。1不是素数): 法一:暴力法 就是从2开始到n - 1依次判断,n % i == 0 则不是素数 法二:筛选 一个数如果是合数,那么可以因式
阅读全文
摘要:Valid Palindrome Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note: For the purpose o
阅读全文
摘要:Valid Palindrome II Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. Example 1: Example 2
阅读全文
摘要:*LeetCode--Add Binary *LeetCode--Add Two Numbers
阅读全文
摘要:Valid Parentheses Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input stri
阅读全文
摘要:Add Two Numbers 两数之和,本位和进位的求和 You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order
阅读全文
摘要:Add Binary 二进制加法 注意考虑本位和进位 Given two binary strings, return their sum (also a binary string). The input strings are both non-empty and contains only c
阅读全文
摘要:Repeated Substring Pattern Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the su
阅读全文
摘要:Ransom Note Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true
阅读全文
摘要:Given a paragraph and a list of banned words, return the most frequent word that is not in the list of banned words. It is guaranteed there is at leas
阅读全文
摘要:Count Binary Substrings Give a string s, count the number of non-empty (contiguous) substrings that have the same number of 0's and 1's, and all the 0
阅读全文
摘要:Detect Capital Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be ri
阅读全文
摘要:Goat Latin A sentence S is given, composed of words separated by spaces. Each word consists of lowercase and uppercase letters only. We would like to
阅读全文
摘要:对于不是对于单个字符进行操作,而是对单词进行操作时,可以选择一些库函数 常用的有: 1. str.split(" "); 按照空格将字符串进行划分,得到字符串数组 注:这里使用的是正则表达式,当要将一片空格分开,可以采用str.split("\\s+")或者str.split(" +") 如果spl
阅读全文
摘要:Reverse String II 自己的解法: 就是用一个StringBuffer来进行字符串的接收,利用一个指针来指示当前是哪一个k部分,当 i + k < s.length() 时,证明从 i 到 i + k - 1部分是可以进行反转的,而从i + k 部分到 i + 2 * k部分是直接进行
阅读全文
1

浙公网安备 33010602011771号