
LeetCode刷题
leetCode刷题,提高内功
u_hcy2000
这个作者很懒,什么都没留下…
展开
-
一、LeetCode 刷题之数据类型溢出问题(1)
文章目录1:Reverse Integer1:Reverse Integer题目描述:输入:红圈的范围输出:整数的翻转分析:考察,int类型整数的取值范围样例输入:1534236469,翻转后9*******5时,在乘以10得90多亿超出20多亿的int范围解决办法:在乘以10之前判断,超过了就返回0,break掉private static int reverse(int x) { int num = 0; int yu; while (x != 0) {原创 2020-10-20 21:55:39 · 463 阅读 · 0 评论 -
LeetCode(二)387. First Unique Character in a String
题目描述Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1.Examples:s = “leetcode”return 0.s = “loveleetcode”,return 2.Note: You may ...原创 2018-12-02 20:48:16 · 216 阅读 · 0 评论 -
LeetCode(四)101. Symmetric Tree
问题描述:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).Note:Bonus points if you could solve it both recursively and iteratively.解题思路:递归的方法,每次递归的调用判断左子...原创 2018-12-04 23:06:56 · 149 阅读 · 0 评论 -
LeetCode(一)Reverse Words in a String III
题目描述:Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example 1:Input: “Let’s take LeetCode contes...原创 2018-12-01 20:45:55 · 148 阅读 · 0 评论 -
LeetCode(六)104. 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 chi...原创 2018-12-07 21:52:48 · 100 阅读 · 0 评论 -
LeetCode(五)102. Binary Tree Level Order Traversal
题目描述:Given 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 / ...原创 2018-12-05 23:16:11 · 96 阅读 · 0 评论 -
LeetCode(三)58. Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ’ ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is defined...原创 2018-12-03 20:40:44 · 167 阅读 · 0 评论 -
LeetCode(七)105. Construct Binary Tree from Preorder and Inorder Traversal
问题描述:Given 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 = [9...原创 2018-12-09 23:11:11 · 176 阅读 · 0 评论 -
LeetCode(八)107. Binary Tree Level Order Traversal II
问题描述:Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree [3,9,20,null,null...原创 2018-12-10 22:54:34 · 141 阅读 · 0 评论