自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(199)
  • 收藏
  • 关注

原创 LeetCode 0367 Valid Perfect Square【验证完美平方数】

Given a positive integer num, write a function which returns True if num is a perfect square else False.Note: Do not use any built-in library function such as sqrt.Example 1:Input: 16Output: trueExample 2:Input: 14Output: false题意判断指定的数是否是平方数

2020-05-09 15:52:27 242

原创 PAT A1019 General Palindromic Number(20)【普通回文数,进位制】

A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers.Although palindromic numbers are most often considered

2020-05-09 15:39:12 251

原创 LeetCode 1232 Check If It Is a Straight Line【 缀点成线,数学】

题目链接 1232. Check If It Is a Straight Line | 1232. 缀点成线You are given an array coordinates, coordinates[i] = [x, y], where [x, y] represents the coordinate of a point. Check if these points make a s...

2020-05-08 15:30:37 235

原创 LeetCode 0383 Ransom Note【赎金信,哈希】

题目链接 383. Ransom Note |Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constru...

2020-05-08 14:59:23 185

原创 LeetCode 0771 Jewels and Stones【宝石与石头,哈希】

题目链接 771. Jewels and Stones |You’re given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You ...

2020-05-08 14:47:12 206

原创 LeetCode 0278 First Bad Version【第一个错误的版本,二分】

题目链接 278.First Bad Version |You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each ...

2020-05-08 14:24:36 159

原创 task5

fsfdsfds

2020-05-01 22:50:54 301

原创 7-3 垃圾分类 (20分)

据香港《南华早报》2019年7月15日文章,上海严格的垃圾分类新规令不少居民抓狂。这催生出大量帮助找出正确分类答案的App和小程序。目前仅微信上就至少有280种与垃圾处理有关的App,在苹果应用商店也达130种。支付宝表示,已有60多家独立App开发商申请为该平台提供类似服务。本题就请你现场实现一个简单的垃圾分类小助手。输入格式:输入首先给出官方分类指南中每种物品的归属。在一行中给出一个正整...

2020-05-01 20:09:43 2856 7

原创 7-2 三阶幸福数 (20分)

对一个十进制数的各位数字做一次立方和,称作一次迭代。如果一个十进制数能通过 h 次迭代得到 1,就称该数为三阶幸福数,迭代的次数 h 称为幸福度。例如 1579 经过 1 次迭代得到 1198,2 次迭代后得到 1243,3 次迭代后得到 100,最后得到 1。则 1579 是幸福数,其幸福度为 4。另一方面,如果一个大于1的数字经过数次迭代后进入了死循环,那这个数就不幸福。例如 97 迭代得到...

2020-05-01 20:09:05 1293 5

原创 7-1 Knuth洗牌法 (20分)

Knuth 洗牌法是生成 { 1, 2, …, n } 的一个随机重排列的算法。与每次反复随机生成一个数字,直到获得一个不重复的新数字的算法不同,Knuth 洗牌法从原始序列 { 1, 2, …, n } 开始,逐次洗牌。洗牌的方法是从左到右,每轮从没确定的数字中随机抽取一个数,把它放到确定的位置上。例如令 n 等于 4。我们从 { 1, 2, 3, 4 } 开始。记 i 到 N 之间的随机抽牌...

2020-05-01 20:08:27 481

原创 PAT A1020 Tree Traversals(25)【树的遍历】

Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of the cor...

2020-04-28 22:57:57 323

原创 Task4

占坑

2020-04-28 21:17:58 303

原创 LeetCode 0589 N-ary Tree Preorder Traversal【N叉树,DFS】

Given an n-ary tree, return the preorder traversal of its nodes’ values.Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null va...

2020-04-26 23:22:08 414

原创 LeetCode 0590 N-ary Tree Postorder Traversal【N叉树,DFS】

Given an n-ary tree, return the postorder traversal of its nodes’ values.Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null v...

2020-04-26 23:22:01 418

原创 LeetCode 0104 Maximum Depth of Binary Tree 【二叉树】

Given 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....

2020-04-26 23:21:58 151

原创 LeetCode 0112 Path Sum 【二叉树】

Given 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 children.Example:G...

2020-04-26 23:21:34 165

原创 LeetCode 0116 Populating Next Right Pointers in Each Node【二叉树,BFS】

You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition:struct Node { int val; Node *left; No...

2020-04-26 23:21:25 140

原创 LeetCode 0236.Lowest Common Ancestor of a Binary Tree【二叉树】

Given 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 a...

2020-04-26 23:21:17 161

原创 LeetCode 0117 Populating Next Right Pointers in Each Node II【二叉树,BFS】

Given a binary treestruct Node { int val; Node *left; Node *right; Node *next;}Populate each next pointer to point to its next right node. If there is no next right node, the next pointer ...

2020-04-26 23:21:03 142

原创 LeetCode 0235 Lowest Common Ancestor of a Binary Search Tree【二叉搜索树,LCA】

Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between t...

2020-04-26 23:19:58 142

原创 LeetCode 0703 Kth Largest Element in a Stream【优先队列,堆】

Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element.Your KthLargest class will have a constructor whi...

2020-04-26 23:19:50 110

原创 LeetCode 0404 Sum of Left Leaves【左边叶节点数量,二叉树,递归】

Find the sum of all left leaves in a given binary tree.Example: 3 / \ 9 20 / \ 15 7There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24....

2020-04-26 23:19:13 128

原创 LeetCode 0111 Minimum Depth of Binary Tree【二叉树,最小深度,递归】

Given 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: A leaf is a node with no children....

2020-04-26 23:18:52 128

原创 LeetCode 0101 Symmetric Tree【二叉树,树的对称,递归】

题目链接 LeetCode | 力扣Given 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 / ...

2020-04-25 13:12:27 134

原创 LeetCode 0572 Subtree of Another Tree【二叉树,递归】

题目链接 LeetCode | 力扣Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a tree consists of a node in s...

2020-04-25 13:09:41 125

原创 LeetCode 0437 Path Sum III【二叉树,递归】

You are given a binary tree in which each node contains an integer value.Find the number of paths that sum to a given value.The path does not need to start or end at the root or a leaf, but it must ...

2020-04-25 12:48:41 142

原创 LeetCode 0112 Path Sum【二叉树,DFS,递归】

Given 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 children.Example:G...

2020-04-25 12:30:42 157

原创 LeetCode 0226 Invert Binary Tree【树,翻转二叉树,DFS,递归】

题目链接 LeetCode | [力扣]Invert a binary tree.Example:Input: 4 / \ 2 7 / \ / \1 3 6 9Output: 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspir...

2020-04-25 12:02:51 127

原创 LeetCode 0543 Diameter of Binary Tree【二叉树直径,DFS,递归】

Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may n...

2020-04-25 11:55:26 153

原创 LeetCode 0104 Maximum Depth of Binary Tree【树的深度,DFS,递归】

Given 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....

2020-04-25 11:38:04 123

原创 LeetCode 0110 Balanced Binary Tree【平衡二叉树,dfs】

Given 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 of every node differ in heig...

2020-04-25 11:24:00 167

原创 LeetCode 0108 Convert Sorted Array to Binary Search Tree【二叉搜索树】

Given 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 defined as a binary tree in which the depth of the ...

2020-04-25 11:22:58 129

原创 Task3 EM

占坑

2020-04-25 11:21:15 254

原创 LeetCode 0701 Insert into a Binary Search Tree【二叉搜索树插入】

Given the root node of a binary search tree (BST) and a value to be inserted into the tree, insert the value into the BST. Return the root node of the BST after the insertion. It is guaranteed that th...

2020-04-24 16:02:01 135

原创 LeetCode 0700 Search in a Binary Search Tree【二叉搜索树】

Given the root node of a binary search tree (BST) and a value. You need to find the node in the BST that the node’s value equals the given value. Return the subtree rooted with that node. If such node...

2020-04-24 15:58:30 129

原创 LeetCode 0173 Binary Search Tree Iterator【二叉搜索树】

Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.Example:BSTIterat...

2020-04-24 15:54:10 131

原创 LeetCode 0098 Validate Binary Search Tree【二叉搜索树】

Given 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 ri...

2020-04-24 15:40:58 183

原创 Task2 bayes_plus

占坑

2020-04-23 18:56:41 315

原创 LeetCode 0516 Longest Palindromic Subsequence【DP,最长回文子序列】

Given a string s, find the longest palindromic subsequence’s length in s. You may assume that the maximum length of s is 1000.Example 1:Input:"bbbab"Output:4One possible longest palindromic su...

2020-04-22 20:58:01 142

原创 LeetCode 0053. Maximum Subarray【DP,最大子序和】

Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4],Output: 6Explanatio...

2020-04-22 19:32:17 186

空空如也

空空如也

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

TA关注的人

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