- 博客(81)
- 资源 (2)
- 收藏
- 关注

原创 206. Reverse Linked List(图解)
206. Reverse Linked ListReverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLSolutionC++Sol1:/** * Definition for singly-linked list. * struct ListNode { * int val; * L
2020-10-07 22:19:06
415

原创 121. Best Time to Buy and Sell Stock(图解)
121. Best Time to Buy and Sell StockSay you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm
2020-10-07 11:44:23
201

原创 33. Search in Rotated Sorted Array(图解)
33. Search in Rotated Sorted ArraySuppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).You are given a target value to search. If found in the array return its
2020-09-03 00:40:39
65

原创 78. Subsets(图解)
78. SubsetsGiven a set of distinct integers, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.Example:Input: nums = [1,2,3]Output:[ [3], [1], [2], [1,2,3], [1,3], [2,3], [1,2],
2020-07-11 18:56:25
248
原创 Bert NER 实战
目录0. 比赛介绍1. Bert NER Finetune数据准备原始数据数据转换模型训练0. 比赛介绍本项目来自 Kaggle 的 NER 比赛:比赛链接此 pipeline 及 code 参考自https://www.kaggle.com/tungmphung/coleridge-matching-bert-ner?select=kaggle_run_ner.pyhttps://www.kaggle.com/tungmphung/pytorch-bert-for-named-entity-r
2021-04-22 15:16:07
818
1
原创 利用火焰图分析 Python 程序性能
1. cProfilecProfile是Python标准库中内置的性能分析模块,C扩展,非侵入式,不需要修改代码。你可以用两种调用方法:命令行调用python -m cProfile [-s sort_order] myscripy.py常用的 sort 类型有两个:1. tottime,指的是函数本身的运行时间,扣除了子函数的运行时间2. cumtime,指的是函数的累计运行时间,包含了子函数的运行时间代码调用有时不方便命令行调用,可以直接在代码中加入:import cPro
2020-11-24 14:08:57
4040
1
原创 5. Longest Palindromic Substring(图解)
5. Longest Palindromic SubstringGiven a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example 1:Input: "babad"Output: "bab"Note: "aba" is also a valid answer.Example 2:Input: "cbbd"Outpu
2020-10-30 00:01:11
249
原创 46. Permutations(图解)
46. PermutationsGiven a collection of distinct integers, return all possible permutations.Example:Input: [1,2,3]Output:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]SolutionC++class Solution {public: vector<vector<
2020-10-19 23:38:41
170
原创 84. Largest Rectangle in Histogram(图解)
84. Largest Rectangle in HistogramGiven n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where width of each bar is 1, given height
2020-10-18 10:12:06
141
原创 297. Serialize and Deserialize Binary Tree(图解)
297. Serialize and Deserialize Binary TreeSerialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructe
2020-10-18 10:11:38
249
原创 98. Validate Binary Search Tree(图解)
98. Validate Binary Search TreeGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node’s key.The right subtree of a node con
2020-10-18 10:11:10
330
原创 236. Lowest Common Ancestor of a Binary Tree(图解)
236. Lowest Common Ancestor of a Binary TreeGiven a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the
2020-10-15 00:24:07
167
原创 283. Move Zeroes(图解)
TitleProblemExample:contentSolutionC++cppPythonpython
2020-10-15 00:23:26
115
原创 22. Generate Parentheses(图解)
22. Generate ParenthesesGiven n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.Example 1:Input: n = 3Output: ["((()))","(()())","(())()","()(())","()()()"]Example 2:Input: n = 1Output: ["()"]Solutio
2020-10-15 00:23:01
151
原创 17. Letter Combinations of a Phone Number(图解)
17. Letter Combinations of a Phone NumberGiven a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order.A mapping of digit to letters (just like on the telephon
2020-10-15 00:22:38
118
原创 15. 3Sum(图解)
15. 3SumGiven an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Notice that the solution set must not contain duplicate triplets.Example 1:Input: n
2020-10-13 23:50:56
306
原创 10. Regular Expression Matching(图解)
10. Regular Expression MatchingGiven an input string (s) and a pattern §, implement regular expression matching with support for ‘.’ and ‘*’ where:‘.’ Matches any single character.‘*’ Matches zero or more of the preceding element.The matching shou
2020-10-08 20:44:57
447
原创 105. Construct Binary Tree from Preorder and Inorder Traversal(图解)
105. Construct Binary Tree from Preorder and Inorder TraversalGiven preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.For example, givenpreorder = [3,9,20,15,7]inorder = [
2020-10-07 11:47:20
282
原创 124. Binary Tree Maximum Path Sum(图解)
124. Binary Tree Maximum Path SumGiven a non-empty binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path must conta
2020-10-07 11:43:04
189
原创 104. Maximum Depth of Binary Tree(图解)
104. Maximum Depth of Binary TreeGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Note: A leaf is a node with no children.Example:Given binary
2020-10-05 18:09:16
155
原创 102. Binary Tree Level Order Traversal(图解)
102. Binary Tree Level Order TraversalGiven a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).For example:Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7re
2020-10-05 18:08:39
273
原创 101. Symmetric Tree(图解)
101. Symmetric TreeGiven a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the following [1,2,2,null,3,null,3]
2020-10-05 18:07:28
220
原创 215. Kth Largest Element in an Array(图解)
215. Kth Largest Element in an ArrayFind the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.Example 1:Input: [3,2,1,5,6,4] and k = 2Output: 5Example 2:Input: [3,2,3
2020-10-04 10:21:31
121
原创 94. Binary Tree Inorder Traversal(图解)
94. Binary Tree Inorder TraversalGiven the root of a binary tree, return the inorder traversal of its nodes’ values.Example:Input: root = [1,null,2,3]Output: [1,3,2]Example 2:Input: root = []Output: []Example 3:Input: root = [1]Output: [1]So
2020-10-04 10:14:05
170
原创 160. Intersection of Two Linked Lists(图解)
160. Intersection of Two Linked ListsWrite a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:begin to intersect at node c1.Example 1:Input: intersectVal = 8, listA = [4
2020-10-03 20:16:42
155
原创 240. Search a 2D Matrix II(图解)
240. Search a 2D Matrix IIWrite an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right.Integers in each column are sorted in ascending
2020-10-02 11:30:12
78
原创 234. Palindrome Linked List(图解)
234. Palindrome Linked ListGiven a singly linked list, determine if it is a palindrome.Example 1:Input: 1->2Output: falseExample 2:Input: 1->2->2->1Output: trueSolutionC++/** * Definition for singly-linked list. * struct ListNode
2020-10-02 11:29:42
155
原创 148. Sort List(图解)
148. Sort ListGiven the head of a linked list, return the list after sorting it in ascending order.Follow up: Can you sort the linked list in O(n logn) time and O(1) memory (i.e. constant space)?Example 1:Input: head = [4,2,1,3]Output: [1,2,3,4]Exam
2020-10-02 11:29:16
192
原创 155. Min Stack(图解)
155. Min StackDesign a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) – Push element x onto stack.pop() – Removes the element on top of the stack.top() – Get the top element.getMin() – Retrieve the mini
2020-10-02 11:28:37
83
原创 152. Maximum Product Subarray(图解)
152. Maximum Product SubarrayGiven an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.Example 1:Input: [2,3,-2,4]Output: 6Explanation: [2,3] has the largest product 6.Ex
2020-10-02 09:22:09
129
原创 141. Linked List Cycle(图解)
141. Linked List CycleGiven head, the head of a linked list, determine if the linked list has a cycle in it.There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internal
2020-09-28 21:09:35
216
原创 169. Majority Element(图解)
169. Majority ElementGiven an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element always exist in the array.Example 1:I
2020-09-28 21:09:10
102
原创 146. LRU Cache(图解)
146. LRU CacheDesign a data structure that follows the constraints of a Least Recently Used (LRU) cache.Implement the LRUCache class:LRUCache(int capacity) Initialize the LRU cache with positive size capacity.int get(int key) Return the value of the k
2020-09-28 21:08:41
202
原创 198. House Robber(图解)
198. House RobberYou 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 i
2020-09-28 21:08:07
149
原创 139. Word Break(图解)
139. Word BreakGiven a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.Note:The same word in the dictionary may be reused
2020-09-27 21:43:50
285
原创 238. Product of Array Except Self(图解)
238. Product of Array Except SelfGiven an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Example:Input: [1,2,3,4]Output: [24,12,8,6]Constraint:
2020-09-27 21:40:15
72
原创 Linux 基础命令
目录Linux 基础常用命令Linux 基础常用命令ls — Listls会列举出当前工作目录的内容(文件或文件夹)。mkdir — Make Directorymkdir 用于新建一个新目录。pwd — Print Working Directory显示当前工作目录。cd — Change Directory切换文件路径,cd 将给定的文件夹(或目录)设置成当前工作目录。rmdir — Remove Directory删除给定的目录。rm — Remove
2020-09-23 14:29:24
104
原创 279. Perfect Squares(图解)
279. Perfect SquaresGiven a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, …) which sum to n.Example 1:Input: n = 12Output: 3 Explanation: 12 = 4 + 4 + 4.Example 2:Input: n = 13Output: 2Explanation:
2020-09-23 00:13:52
130
原创 207. Course Schedule(图解)
207. Course ScheduleThere are a total of numCourses courses you have to take, labeled from 0 to numCourses-1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1]Given the
2020-09-23 00:10:02
343
原创 200. Number of Islands(图解)
200. Number of IslandsGiven a 2d grid map of '1’s (land) and '0’s (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are a
2020-09-22 08:55:38
91
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人