自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

memcpy0的博客

自由软件给我自由!

  • 博客(131)
  • 资源 (8)
  • 收藏
  • 关注

原创 【算法学习】图论专题 判断无向图中环的存在、环的输出

文章目录一、无向图 Detect Cycle in a Undirected Graph1. DFS(1) 判断环的存在(2) 输出环路2. BFS(1) 判断环的存在3. Union-Find(1) 原理讲解(2) 代码实现二、有向图 Detect Cycle in a Directed Graph1. Detect Cycle in a Directed GraphDetect Cycle in a Directed Graph using BFSDetect Cycle in a directed g

2020-11-30 17:38:20 11558 1

原创 LeetCode 767. Reorganize String【贪心,堆,计数】中等

Given a string S , check if the letters can be rearranged so that two characters that are adjacent to each other are not the same.If possible, output any possible result. If not possible, return the empty string.Example 1:Input: S = "aab"Output: "aba"

2020-11-30 16:09:37 271

原创 LeetCode C++ 面试题 08.07. Permutation I LCCI【Backtracking/Recursion】中等

Write a method to compute all permutations of a string of unique characters.Example1:Input: S = "qwe"Output: ["qwe", "qew", "wqe", "weq", "ewq", "eqw"]Example2:Input: S = "ab"Output: ["ab", "ba"]Note:All charaters are English letters.1 <= S.

2020-11-30 15:10:49 250

原创 LeetCode C++ 513. Find Bottom Left Tree Value【Tree/DFS/BFS】中等

Given a binary tree, find the leftmost value in the last row of the tree.Example 1:Input: 2 / \ 1 3Output:1Example 2:Input: 1 / \ 2 3 / / \ 4 5 6 / 7Output:7Note: You may assume t

2020-11-30 13:06:33 268

原创 LeetCode C++ 976. Largest Perimeter Triangle【Greedy/Sort】简单

Given an array A of positive lengths, return the largest perimeter of a triangle with non-zero area, formed from 3 of these lengths.If it is impossible to form any triangle of non-zero area, return 0.Example 1:Input: [2,1,2]Output: 5Example 2:Input:

2020-11-30 12:44:30 267

原创 【算法学习】搜索专题 排列、组合和子集生成

文章目录一、递归和排列二、子集生成三、组合生成搜索是基础的编程技术,是基础中的基础,非常非常重要,而且也有难度。我们必须认真学习。搜索体现了暴力法的思想,有很多用途:很多问题只能用暴力搜索解决,如猜密码。对小规模的数据,完全足够,而且简单不易出错。暴力法往往用于参照,可以从它出发,逐步思考更高级的算法,而且在生成测试数据进行对拍上面很有用。暴力法往往可以进行优化,使用剪枝跳过不符合要...

2020-11-30 11:50:12 437

原创 LeetCode C++ 面试题 08.04. Power Set LCCI【Bit Manipulation/Recursion】中等

Write a method to return all subsets of a set. The elements in a set are pairwise distinct.Note: The result set should not contain duplicated subsets.Example:Input: nums = [1,2,3]Output: [ [3], [1], [2], [1,2,3], [1,3], [2,3], [1,2], []]题意

2020-11-28 15:32:05 225

原创 LeetCode C++ 454. 4Sum II【Hash Table/Sort/Two Pointers/Binary Search】中等

Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero.To make problem a bit easier, all A, B, C, D have same length of N where 0 ≤ N ≤ 500. All integers are in the range o

2020-11-28 14:27:10 305

原创 LeetCode C++ 1302. Deepest Leaves Sum【Tree/BFS/DFS】中等

Given a binary tree, return the sum of values of its deepest leaves.Example 1:Input: root = [1,2,3,4,5,null,6,7,null,null,null,null,8]Output: 15Constraints:The number of nodes in the tree is between 1 and 10^4.The value of nodes is between 1 and 1

2020-11-27 01:22:22 315

原创 LeetCode C++ 面试题 08.05. Recursive Mulitply LCCI【Recursion/Math】中等

Write a recursive function to multiply two positive integers without using the * operator. You can use addition, subtraction, and bit shifting, but you should minimize the number of those operations.Example 1:Input: A = 1, B = 10Output: 10Example 2:I

2020-11-27 00:37:24 299

原创 LeetCode C++ 面试题 04.06. Successor LCCI【Binary Search Tree/DFS】中等

Write an algorithm to find the “next” node (i.e., in-order successor) of a given node in a binary search tree.Return null if there’s no “next” node for the given node.Example 1:Input: root = [2,1,3], p = 1 2 / \1 3Output: 2Example 2:Input: r

2020-11-26 23:20:54 241

原创 LeetCode C++ 面试题 04.05. Legal Binary Search Tree LCCI【Binary Search Tree/DFS】中等

Implement a function to check if a binary tree is a binary search tree.Example 1:Input: 2 / \ 1 3Output: trueExample 2:Input: 5 / \ 1 4 / \ 3 6Output: falseExplanation: Input: [5,1,4,null,null,3,6]. the value o

2020-11-26 22:28:55 198

原创 LeetCode 372. Super Pow【数学/递归/快速幂】中等

Your task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array.Example 1:Input: a = 2, b = [3]Output: 8Example 2:Input: a = 2, b = [1,0]Output: 1024Example 3:Input: a

2020-11-26 02:13:24 272

原创 LeetCode C++ 50. Pow(x, n)【Recursion】中等

Implement pow(x, n), which calculates x raised to the power n (i.e. xn).Example 1:Input: x = 2.00000, n = 10Output: 1024.00000Example 2:Input: x = 2.10000, n = 3Output: 9.26100Example 3:Input: x = 2.00000, n = -2Output: 0.25000Explanation:

2020-11-26 02:11:58 288

原创 LeetCode C++ 剑指 Offer 16. 数值的整数次方【Math/Recursion】中等

实现函数double Power(double base, int exponent),求base的exponent次方。不得使用库函数,同时不需要考虑大数问题。示例 1:输入: 2.00000, 10输出: 1024.00000示例 2:输入: 2.10000, 3输出: 9.26100示例 3:输入: 2.00000, -2输出: 0.25000解释: 2-2 = 1/22 = 1/4 = 0.25说明: -100.0 < x 

2020-11-26 01:59:54 253

原创 LeetCode C++ 102. 二叉树的层序遍历【Tree/BFS】中等

给你一个二叉树,请你返回其按 层序遍历 得到的节点值。 (即逐层地,从左到右访问所有节点)。示例:二叉树:[3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7返回其层次遍历结果:[ [3], [9,20], [15,7]]解法 BFSclass Solution {public: vector<vector<int>> levelOrder(TreeNode* root

2020-11-26 00:53:42 182

原创 LeetCode C++ 剑指 Offer 32 - I. 从上到下打印二叉树【Tree/BFS】中等

从上到下打印出二叉树的每个节点,同一层的节点按照从左到右的顺序打印。例如,给定二叉树 [3,9,20,null,null,15,7] : 3 / \ 9 20 / \ 15 7返回[3,9,20,15,7]提示:节点总数 <= 1000解法 BFSclass Solution {public: vector<int> levelOrder(TreeNode* root) { if (root == null

2020-11-26 00:45:22 179

原创 LeetCode C++ 剑指 Offer 32 - II. 从上到下打印二叉树 II【Tree/BFS】简单

从上到下按层打印二叉树,同一层的节点按从左到右的顺序打印,每一层打印到一行。例如:给定二叉树 [3,9,20,null,null,15,7] : 3 / \ 9 20 / \ 15 7返回其层次遍历结果:[ [3], [9,20], [15,7]]提示:节点总数 <= 1000解法 BFSclass Solution {public: vector<vector<int>> levelOrder(

2020-11-26 00:40:41 216

原创 LeetCode 287. Find the Duplicate Number【Array/Two Pointers】中等

Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive.There is only one duplicate number in nums, return this duplicate number.Follow-ups:How can we prove that at least one duplicate number must e

2020-11-25 23:39:04 164

原创 LeetCode 142. Linked List Cycle II【链表,哈希表;双指针】

Given a linked list, return the node where the cycle begins. If there is no cycle, return null.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. Internally,

2020-11-25 22:18:41 187

原创 LeetCode C++ 剑指 Offer 12. 矩阵中的路径【DFS】中等

请设计一个函数,用来判断在一个矩阵中是否存在一条包含某字符串所有字符的路径。路径可以从矩阵中的任意一格开始,每一步可以在矩阵中向左、右、上、下移动一格。如果一条路径经过了矩阵的某一格,那么该路径不能再次进入该格子。例如,在下面的 3 × 4 的矩阵中包含一条字符串 “bfce” 的路径(路径中的字母用加粗标出)。[[“a”,“b”,“c”,“e”],[“s”,“f”,“c”,“s”],[“a”,“d”,“e”,“e”]]但矩阵中不包含字符串 “abfb” 的路径,因为字符串的第一个字符 b 占据了矩

2020-11-25 02:03:25 164

原创 LeetCode C++ 面试题 04.03. List of Depth LCCI【Tree/BFS】中等

Given a binary tree, design an algorithm which creates a linked list of all the nodes at each depth (e.g., if you have a tree with depth D, you’ll have D linked lists). Return a array containing all the linked lists.Example:Input: [1,2,3,4,5,null,7,8]

2020-11-25 01:29:46 149

原创 LeetCode C++ 1370. Increasing Decreasing String【String/Hash Table】简单

Given a string s. You should re-order the string using the following algorithm:Pick the smallest character from s and append it to the result.Pick the smallest character from s which is greater than the last appended character to the result and append i

2020-11-25 01:18:37 152

原创 LeetCode 441. Arranging Coins【数学/二分】简单

You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins.Given n, find the total number of full staircase rows that can be formed.n is a non-negative integer and fits within the range of a 32-

2020-11-25 00:47:23 390

原创 LeetCode C++ 200. Number of Islands【DFS/BFS】中等

Given an m x n 2d grid map of '1's (land) and '0's (water), return 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 all surrounded b

2020-11-24 17:55:56 213

原创 LeetCode C++ 289. Game of Life【Array】中等

According to the Wikipedia’s article: “The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.”Given a board with m by n cells, each cell has an initial state live (1) or dead (

2020-11-24 15:10:18 186

原创 LeetCode C++ 面试题 04.02. Minimum Height Tree LCCI【Tree/Recursion】简单

Given a sorted (increasing order) array with unique integer elements, write an algo­rithm to create a binary search tree with minimal height.Example:Given sorted array: [-10,-3,0,5,9],One possible answer is: [0,-3,9,-10,null,5],which represents the fol

2020-11-24 01:22:01 175

原创 LeetCode C++ 面试题 02.06. Palindrome Linked List LCCI【Linked List/Recursion】简单

Implement a function to check if a linked list is a palindrome.Example 1:Input: 1->2Output: false Example 2:Input: 1->2->2->1Output: true Follow up: Could you do it in O(n) time and O(1) space?题意:编写一个函数,检查输入的链表是否是回文的。解法1 辅助空间使用

2020-11-23 23:06:37 160

原创 LeetCode C++ 1662. Check If Two String Arrays are Equivalent【String】简单

Given two string arrays word1 and word2, return true if the two arrays represent the same string, and false otherwise.A string is represented by an array if the array elements concatenated in order forms the string.Example 1:Input: word1 = ["ab", "c"],

2020-11-22 16:46:05 248

原创 洛谷 P1049 装箱问题【01背包】

题目描述有一个箱子容量为VVV(正整数,0≤V≤200000 \le V \le 200000≤V≤20000),同时有nnn个物品(0<n≤300<n \le 300<n≤30,每个物品有一个体积(正整数)。要求nnn个物品中,任取若干个装入箱内,使箱子的剩余空间为最小。输入格式111个整数,表示箱子容量111个整数,表示有nnn个物品接下来nnn行,分别表示这nnn个物品的各自体积输出格式111个整数,表示箱子剩余空间。输入输出样例输入 #12468312

2020-11-21 20:25:38 177

原创 【编译原理】学习笔记 第2章 形式语言概论

本章的主要内容为:文法的形式定义,语言的形式定义,为语言构造文法,和语法分析有关的概念,文法的实用限制。

2020-11-21 17:04:59 789 1

原创 洛谷 P1060 开心的金明【01背包】

题目描述金明今天很开心,家里购置的新房就要领钥匙了,新房里有一间他自己专用的很宽敞的房间。更让他高兴的是,妈妈昨天对他说:“你的房间需要购买哪些物品,怎么布置,你说了算,只要不超过 NNN 元钱就行”。今天一早金明就开始做预算,但是他想买的东西太多了,肯定会超过妈妈限定的 NNN 元。于是,他把每件物品规定了一个重要度,分为 555 等:用整数 1−51-51−5 表示,第 555 等最重要。他还从因特网上查到了每件物品的价格(都是整数元)。他希望在不超过 NNN 元(可以等于 NNN 元)的前提下,使每

2020-11-21 15:31:12 211

原创 洛谷 P1048 采药【01背包】

题目描述辰辰是个天资聪颖的孩子,他的梦想是成为世界上最伟大的医师。为此,他想拜附近最有威望的医师为师。医师为了判断他的资质,给他出了一个难题。医师把他带到一个到处都是草药的山洞里对他说:“孩子,这个山洞里有一些不同的草药,采每一株都需要一些时间,每一株也有它自身的价值。我会给你一段时间,在这段时间里,你可以采到一些草药。如果你是一个聪明的孩子,你应该可以让采到的草药的总价值最大。”如果你是辰辰,你能完成这个任务吗?输入格式第一行有 222 个整数 TTT(1≤T≤10001 \le T \le 10

2020-11-21 10:01:43 185

原创 LeetCode C++ 面试题 05.01. Insert Into Bits LCCI【Bit Manipulation】简单

You are given two 32-bit numbers, N and M, and two bit positions, i and j. Write a method to insert M into N such that M starts at bit j and ends at bit i. You can assume that the bits j through i have enough space to fit all of M. That is, if M = 10011, y

2020-11-17 17:38:11 193

原创 LeetCode C++ 面试题 08.10. Color Fill LCCI【DFS/BFS】简单

Implement the “paint fill” function that one might see on many image editing programs. That is, given a screen (represented by a two-dimensional array of colors), a point, and a new color, fill in the surrounding area until the color changes from the origi

2020-11-17 15:51:40 193

原创 LeetCode C++ 面试题 08.06. Hanota LCCI【Stack/Recursion】简单

In the classic problem of the Towers of Hanoi, you have 3 towers and N disks of different sizes which can slide onto any tower. The puzzle starts with disks sorted in ascending order of size from top to bottom (i.e., each disk sits on top of an even larger

2020-11-17 15:18:39 252

原创 LeetCode C++ 1030. Matrix Cells in Distance Order【Sort/BFS】简单

We are given a matrix with R rows and C columns has cells with integer coordinates (r, c), where 0 <= r < R and 0 <= c < C.Additionally, we are given a cell in that matrix with coordinates (r0, c0).Return the coordinates of all cells in the m

2020-11-17 10:30:41 201

原创 LeetCode C++ 160. Intersection of Two Linked Lists【Linked List/Two Pointers】简单

Write 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,1,8,4,5], listB = [5,6,1,8,4,5], skip

2020-11-17 01:10:45 160

原创 LeetCode C++ 面试题 03.06. Animal Shelter LCCI【Queue/Design】简单

enqueue method has a animal parameter, animal[0] represents the number of the animal, animal[1] represents the type of the animal, 0 for cat and 1 for dog.dequeue* method returns [animal number, animal type], if there’s no animal that can be adopted, retu

2020-11-17 00:32:53 259 1

原创 LeetCode C++ 172. Factorial Trailing Zeroes【Math】简单

Given an integer n, return the number of trailing zeroes in n!.Follow up: Could you write a solution that works in logarithmic time complexity?Example 1:Input: n = 3Output: 0Explanation: 3! = 6, no trailing zero.Example 2:Input: n = 5Output: 1Exp

2020-11-16 00:14:02 147

西电软件工程概论考前复习题

西电软件工程概论考前复习题

2022-06-25

chapter1_7.zip

Orange's操作系统一书的相关资源,1-7章,个人在Ubuntu虚拟机上运行过

2021-07-15

rubyinstaller-devkit-3.0.1-1-x64.exe

官网下载太慢,这里是我分享的安装包

2021-06-30

编程小白的第一本Python入门书

一个实用主义的开发者,带你快速走进Python编程的大门。

2018-04-30

Coursera机器学习笔记

吴恩达教授的Coursera机器学习笔记整理一到一十八章全

2018-04-22

Python编程

很有趣的一本Python书,学完后可以做各种项目了,对入门的读者是很大的提升

2018-04-22

简明Python教程

简明Python教程,讲解了Python2编程的各个方面,虽然论述和代码实例都很简洁,但是讲解清晰,是不错的入门书籍

2018-04-22

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除