Xiaoliji's Blog

小里脊的个人博客


  • Home

  • Categories

  • Tags

  • Archives

  • About

  • Search

LeetCode算法题整理(位运算篇)Bit Manipulation

Posted on 2018-08-30   |   Updated on 2022-10-21 | In 算法 | | Visitors

191. Number of 1 Bits

计算数字的二进制中有多少个1。原题

1
2
3
Input: 11
Output: 3
Explanation: Integer 11 has binary representation 00000000000000000000000000001011
Read more »

LeetCode算法题整理(设计篇)Design

Posted on 2018-08-15   |   Updated on 2021-04-12 | In 算法 | | Visitors

155. Min Stack

设计一个栈,要求在常数时间复杂度取出最小值。原题

Read more »

LeetCode算法题整理(字符串篇)String

Posted on 2018-08-12   |   Updated on 2020-11-02 | In 算法 | | Visitors

14. Longest Common Prefix

返回最长公共前缀字符串。原题

1
2
Input: ["flower","flow","flight"]
Output: "fl"
Read more »

LeetCode算法题整理(链表篇)LinkedList

Posted on 2018-08-09   |   Updated on 2021-03-28 | In 算法 | | Visitors

链表的定义

1
2
3
4
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
Read more »

LeetCode算法题整理(二分法篇)Binary Search

Posted on 2018-08-30   |   Updated on 2022-11-17 | In 算法 | | Visitors

704. Binary Search

二分法在有序数组中查找元素。原题

1
2
3
Input: nums = [-1,0,3,5,9,12], target = 9
Output: 4
Explanation: 9 exists in nums and its index is 4
Read more »

LeetCode算法题整理(贪心篇)Greedy

Posted on 2019-01-27   |   Updated on 2021-03-28 | In 算法 | | Visitors

984. String Without AAA or BBB

生成字符串没有‘aaa’和’bbb’。原题

1
2
3
Input: A = 1, B = 2
Output: "abb"
Explanation: "abb", "bab" and "bba" are all correct answers.
Read more »

LeetCode算法题整理(单词查找树篇)Trie

Posted on 2019-04-07   |   Updated on 2020-08-24 | In 算法 | | Visitors

此篇为预留篇章,其中的算法有些还未使用Trie进行优化。

1023. Camelcase Matching

驼峰匹配。原题

1
2
3
4
5
6
7
8
9
10
Input: queries = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], pattern = "FB"
Output: [true,false,true,true,false]
Explanation:
"FooBar" can be generated like this "F" + "oo" + "B" + "ar".
"FootBall" can be generated like this "F" + "oot" + "B" + "all".
"FrameBuffer" can be generated like this "F" + "rame" + "B" + "uffer".

["CompetitiveProgramming","CounterPick","ControlPanel"]
"CooP"
[false,false,true]
Read more »

LeetCode算法题整理(图篇)Graph

Posted on 2019-02-10   |   Updated on 2022-11-23 | In 算法 | | Visitors

990. Satisfiability of Equality Equations

满足所有方程式,判断是否存在变量的值满足所有的等式与不等式。原题

解析:所有的相等的点,在图中是联通的。

Read more »

LeetCode算法题整理(并查集篇)UnionFind

Posted on 2020-12-20   |   Updated on 2021-04-14 | In UnionFind | | Visitors

1697. Checking Existence of Edge Length Limited Paths

给你一个 n 个点组成的无向图边集 edgeList ,其中 edgeList[i] = [ui, vi, disi] 表示点 ui 和点 vi 之间有一条长度为 disi 的边。请注意,两个点之间可能有 超过一条边 。给你一个查询数组queries ,其中 queries[j] = [pj, qj, limitj] ,你的任务是对于每个查询 queries[j] ,判断是否存在从 pj 到 qj 的路径,且这条路径上的每一条边都 严格小于 limitj 。请你返回一个 布尔数组 answer ,其中 answer.length == queries.length ,当 queries[j] 的查询结果为 true 时, answer 第 j 个值为 true ,否则为 false 。

Read more »

LeetCode算法题整理(线段树篇)SegmentTree

Posted on 2020-11-08   |   Updated on 2020-11-08 | In Segment Tree | | Visitors

1649. Create Sorted Array through Instructions

根据指令数组创建一个有序的数组。每次新增数时的花费为,min(小于此数的个数,大于此数的个数)。

Read more »

LeetCode算法题整理(堆篇)Heap

Posted on 2020-10-05   |   Updated on 2021-02-23 | In Heap | | Visitors

1606. Find Servers That Handled Most Number of Requests

有k个服务器处理一些请求,第i个请求需要第i%k服务器来处理,如果服务器繁忙,则按序号向下找;找到末尾后再从头开始,如果所有的服务器都忙,那么该请求被丢弃。给定一些请求的到达时间和需要处理的时间,问处理最多个请求的服务器有哪些。

Read more »

LeetCode算法题整理(并发篇)Threading

Posted on 2020-09-22   |   Updated on 2020-09-22 | In Concurrency | | Visitors

1114. Print in Order

按照指定的顺序打印,三个线程的方法。

Read more »

LeetCode算法题整理(回溯篇)BackTracking

Posted on 2019-03-24   |   Updated on 2021-01-14 | In 算法 | | Visitors

93. Restore IP Addresses

恢复IP地址。原题

1
2
Input: "25525511135"
Output: ["255.255.11.135", "255.255.111.35"]
Read more »

LeetCode算法题整理(正则篇)regex

Posted on 2018-10-01   |   Updated on 2018-10-04 | In 算法 | | Visitors

193. Valid Phone Numbers

使用bash命令在一行中提取一个文本中的手机号。原题

Read more »

Python 并行赋值

Posted on 2018-09-08   |   Updated on 2018-09-08 | In Python | | Visitors

经常可以在Python看到这样的赋值语句

Read more »
上一页123下一页
xiaoliji

xiaoliji

38 posts
12 categories
33 tags
GitHub HackerRank LeetCode 简书
© 2023 xiaoliji
本站访客数:
Powered by Hexo
Theme - NexT.Mist
博客全站共232.9k字