搜索
OJ-搜索
小白算法习题记录本
一个刚学算法的超级无敌小白痴。博客里所有的文章都是用来记录我做题时候敲下的代码的,全是水货,无贡献,经不起深敲,主页也没有浏览的必要,蟹蟹!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
113. Path Sum II
Path Sum IIMediumGiven a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum.Note: A leaf is a node with no children.Example:Given the below binary tre...原创 2020-03-23 16:08:34 · 109 阅读 · 0 评论 -
257. Binary Tree Paths
Binary Tree PathsEasyGiven a binary tree, return all root-to-leaf paths.Note: A leaf is a node with no children.Example:Input:1/ 2 35Output: [“1->2->5”, “1->3”]Explanation...原创 2020-03-23 12:58:05 · 125 阅读 · 0 评论 -
559. Maximum Depth of N-ary Tree
Maximum Depth of N-ary TreeEasyGiven a n-ary 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.Nary-T...原创 2020-03-23 12:57:13 · 131 阅读 · 0 评论 -
690. Employee Importance
Employee ImportanceEasyYou are given a data structure of employee information, which includes the employee’s unique id, his importance value and his direct subordinates’ id.For example, employee ...原创 2020-03-23 12:56:35 · 147 阅读 · 0 评论 -
733. Flood Fill
Flood FillEasyAn image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535).Given a coordinate (sr, sc) representing the starting pi...原创 2020-03-23 12:55:18 · 138 阅读 · 0 评论 -
872. Leaf-Similar Trees
Leaf-Similar TreesEasyConsider all the leaves of a binary tree. From left to right order, the values of those leaves form a leaf value sequence.For example, in the given tree above, the leaf val...原创 2020-03-23 12:54:32 · 131 阅读 · 0 评论 -
897. Increasing Order Search Tree
Increasing Order Search TreeEasyGiven a binary search tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and o...原创 2020-03-23 12:37:39 · 106 阅读 · 0 评论 -
112. Path Sum
Path SumEasyGiven a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Note: A leaf is a node with no chil...原创 2020-03-22 22:35:42 · 114 阅读 · 0 评论 -
111. Minimum Depth of Binary Tree
Minimum Depth of Binary TreeEasyGiven a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.Note...原创 2020-03-22 22:34:58 · 101 阅读 · 0 评论 -
110. Balanced Binary Tree
Balanced Binary TreeEasyGiven a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as:a binary tree in which the left and right subtrees o...原创 2020-03-22 22:34:11 · 103 阅读 · 0 评论 -
108. Convert Sorted Array to Binary Search Tree
Convert Sorted Array to Binary Search TreeEasyGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is d...原创 2020-03-22 22:33:27 · 179 阅读 · 0 评论 -
104. Maximum Depth of Binary Tree
Maximum Depth of Binary TreeEasyGiven 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...原创 2020-03-22 22:32:35 · 110 阅读 · 0 评论 -
101. Symmetric Tree
Symmetric TreeEasyGiven 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...原创 2020-03-22 22:31:25 · 104 阅读 · 0 评论 -
100. Same Tree
Same TreeEasyGiven two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same ...原创 2020-03-22 22:30:09 · 89 阅读 · 0 评论 -
1133: 棋盘问题
题目描述PIPI有一个nxn的棋盘,以及k个棋子,它想把这些棋子摆放到棋盘中去。 同一行同一列只能摆放一颗棋子。但是棋盘中有些格子是不能摆放棋子的,它想问你一共有多少不同种的摆放方式?两种摆放方式至少有一颗棋子摆放位置不同时视为不同摆放方式。#表示可以摆放棋子.表示不能摆放棋子输入多组测试数据每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘...原创 2020-03-17 20:14:34 · 1119 阅读 · 0 评论 -
【难】皇后问题,深度搜索
#include<iostream>#include<cstdio>#include<string>using namespace std;int ans[95][10];//定义解空间,1-92有效int row[10];//棋盘的8行,用于存储当前可行解int index=0;void dfs(int current)//current表...原创 2020-02-23 22:44:28 · 175 阅读 · 0 评论
分享