随笔分类 -  LeetCode 华山论剑篇

记录自己的LeetCode刷题日志!
摘要:1. Description 将一个只含有数字0~9和#的字符串按规则转换: 1. '1' ~ '9' -> 'a' ~ 'i';2. "10#" ~ "26#" -> 'j' ~ 'z' 返回最后字符串res。 2. Solution 顺序扫描字符,每次往后多看两个字符(如果可以的话),判断字符所 阅读全文
posted @ 2020-03-19 16:25 SheepCore 阅读(143) 评论(0) 推荐(0)
摘要:1. Description 给定一个整数n,求一个包含n个字符的串,串中每个字符出现奇数次。 2. Solution 分类讨论,如果n为1,返回"a",n为2,返回"ab",n大于2且为偶数,则返回"aaaa...aab"(n-1个a加1个b),n为奇数,直接返回n个a。 3. Code stri 阅读全文
posted @ 2020-03-19 15:33 SheepCore 阅读(153) 评论(0) 推荐(0)
摘要:1. Description 给定一个字符串s,先按从小到大的顺序抽取字符添加到res字符串中,然后按从大到小的顺序抽取字符添加到res末尾,直到原字符串中所有字符抽取完毕。 2. Solution 关键在于先一遍扫描提取每个字符频数,然后向前向后添加,一有字符添加,就要及时将cnt减一。 3. C 阅读全文
posted @ 2020-03-19 15:06 SheepCore 阅读(252) 评论(0) 推荐(0)
摘要:1. Description 给定一个字符串 s 是一个只包含 'L' or 'R' 的平衡串(L 和 R 数目一样多),求可以分成多少个平衡子串。 https://leetcode.com/problems/split-a-string-in-balanced-strings/ 2. Soluti 阅读全文
posted @ 2020-03-19 14:16 SheepCore 阅读(173) 评论(0) 推荐(0)
摘要:1. Description: Notes: 2. Examples: 3.Solutions: /** * Created by sheepcore on 2018-12-24 */ class Solution { public int[] nextGreaterElement(int[] nu 阅读全文
posted @ 2020-03-02 17:00 SheepCore 阅读(125) 评论(0) 推荐(0)
摘要:1. Description: Notes: 2. Examples: 3.Solutions: 1 /** 2 * Created by sheepcore on 2018-12-24 3 */ 4 class Solution { 5 public String removeOuterParen 阅读全文
posted @ 2020-03-02 16:55 SheepCore 阅读(186) 评论(0) 推荐(0)
摘要:1. Description: Notes: 2. Examples: 3.Solutions: 1 /** 2 * Created by sheepcore on 2018-12-24 3 */ 4 class Solution { 5 public int calPoints(String[] 阅读全文
posted @ 2020-03-02 16:51 SheepCore 阅读(152) 评论(0) 推荐(0)
摘要:1. Description: Notes: 2. Examples: 3.Solutions: 1 /** 2 * Created by sheepcore on 2018-12-24 3 */ 4 class Solution { 5 public boolean buddyStrings(St 阅读全文
posted @ 2020-03-02 16:47 SheepCore 阅读(161) 评论(0) 推荐(0)
摘要:1. Description: Notes: 2. Examples: 3.Solutions: 1 /** 2 * Created by sheepcore on 2018-11-11 3 */ 4 class Solution { 5 public String reverseOnlyLette 阅读全文
posted @ 2020-03-02 16:42 SheepCore 阅读(153) 评论(0) 推荐(0)
摘要:1. Description: Notes: 2. Examples: 3.Solutions: 1 class Solution { 2 public int findLUSlength(String a, String b) { 3 return a.equals(b) ? -1 : Math. 阅读全文
posted @ 2020-03-02 16:37 SheepCore 阅读(110) 评论(0) 推荐(0)
摘要:1. Description: Notes: 2. Examples: 3.Solutions: 1 /** 2 * Created by sheepcore on 2018-11-11 3 */ 4 class Solution { 5 public String[] reorderLogFile 阅读全文
posted @ 2020-03-02 16:32 SheepCore 阅读(181) 评论(0) 推荐(0)
摘要:1. Description: 2.Solutions: 1 /** 2 * Created by sheepcore on 2019-01-23 3 */ 4 class Solution { 5 public int[] twoSum(int[] nums, int target) { 6 Ma 阅读全文
posted @ 2020-03-02 16:28 SheepCore 阅读(128) 评论(0) 推荐(0)
摘要:1. Description: Notes: 2. Examples: 3.Solutions: 1 /** 2 * Created by sheepcore on 2019-02-24 3 */ 4 class Solution { 5 public int[] sumEvenAfterQueri 阅读全文
posted @ 2020-03-02 16:23 SheepCore 阅读(198) 评论(0) 推荐(0)
摘要:1. Description: Notes: 2. Examples: 3.Solutions: 1 /** 2 * Created by sheepcore on 2019-02-24 3 */ 4 class Solution { 5 public int arrayPairSum(int[] 阅读全文
posted @ 2020-03-02 16:20 SheepCore 阅读(132) 评论(0) 推荐(0)
摘要:1. Description: Notes: 2. Examples: 3.Solutions: 1 /** 2 * Created by sheepcore on 2019-02-24 3 */ 4 class Solution { 5 public int[][] kClosest(int[][ 阅读全文
posted @ 2020-03-02 16:16 SheepCore 阅读(195) 评论(0) 推荐(0)
摘要:1. Description: Notes: 2. Examples: 3.Solutions: 1 /** 2 * Created by sheepcore on 2019-02-24 3 */ 4 class Solution { 5 public int[] sortArrayByParity 阅读全文
posted @ 2020-03-02 16:11 SheepCore 阅读(131) 评论(0) 推荐(0)
摘要:1. Description: Notes: 2. Examples: 3.Solutions: 1 /** 2 * Created by sheepcore on 2019-02-24 3 */ 4 class Solution { 5 public int numSpecialEquivGrou 阅读全文
posted @ 2020-03-02 16:07 SheepCore 阅读(119) 评论(0) 推荐(0)
摘要:1. Description: 2. Examples: 3.Solutions: 1 /** 2 * Created by sheepcore on 2019-02-24 3 */ 4 class Solution { 5 public void reverseString(char[] s) { 阅读全文
posted @ 2020-03-02 16:04 SheepCore 阅读(149) 评论(0) 推荐(0)
摘要:1. Description: 2.Solutions: 1 /** 2 * Created by sheepcore on 2019-02-24 3 */ 4 class Solution { 5 public String reverseWords(String s) { 6 String[] 阅读全文
posted @ 2020-03-02 16:00 SheepCore 阅读(266) 评论(0) 推荐(0)
摘要:1. Description: 2. Examples: 3.Solutions: 1 /** 2 * Created by sheepcore on 2019-02-24 3 * best time complexity: O(n) 4 * average time complexity: O(n 阅读全文
posted @ 2020-03-02 15:57 SheepCore 阅读(160) 评论(0) 推荐(0)