自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 LeetCode菜鸟进化史day8

LeetCode菜鸟进化史day8 简单部分的最后几个题 589. N-ary Tree Preorder Traversal 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

2020-09-10 13:50:11 313

原创 LeetCode day7

108. 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 two subt

2020-08-27 14:29:04 113

原创 LeetCode day6

371. Sum of Two Integers Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example 1: Input: a = 1, b = 2 Output: 3 Example 2: Input: a = -2, b = 3 Output: 1 分析 加法运算不能用+和-符号,自然可以想到位运算。 ^:异或运算符,实现两个数不考虑进位的加法 &am

2020-08-25 15:04:46 107

原创 LeetCode day6

242. Valid Anagram Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Input: s = “anagram”, t = “nagaram” Output: true Example 2: Input: s = “rat”, t = “car” Output: false Note: You may assume the string contains

2020-08-25 14:13:03 98

原创 LeetCode day6

204. Count Primes Count the number of prime numbers less than a non-negative number, n. Example: Input: 10 Output: 4 Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7. 分析 首先构建一个判断一个数是否为质数的函数,再在给出数以内判断有多少个质数。 代码 #include<iostream&g

2020-08-25 10:47:28 49

原创 LeetCode day6

202.Happy Number Write an algorithm to determine if a number n is “happy”. A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process u

2020-08-25 10:18:52 125

原创 LeetCode day5

169. Majority Element Given 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-08-24 15:28:34 127

原创 LeetCode菜鸟进化史day5

155.Min Stack Design 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 minim

2020-08-24 14:26:20 106

原创 LeetCode菜鸟进化史day4

day4 昨天的草稿没了。。。 141.Linked List Cycle 给定一个链表,确定其中是否有循环。 为了表示给定链表中的循环,我们使用整数pos表示尾部连接到的链表中的位置(0索引)。 如果pos为-1,则链接列表中没有循环。 Example 1: Input: head = [3,2,0,-4], pos = 1 Output: true Explanation: There is a cycle in the linked list, where tail connects to the s

2020-08-14 09:14:15 132

原创 LeetCode菜鸟进化史day3

day3 今天上午阅读刻意练习,困得亚批,希望刻意练习一下阅读不犯困… 21.Merge Two Sorted List 合并两个排序的链表,并将其作为新的排序表返回。 应通过将前两个列表的节点拼接在一起来创建新列表。 Example: Input: 1->2->4, 1->3->4 Output: 1->1->2->3->4->4 分析 此处需要直接定义一个列表对象放与栈上,而不是new一个对象放在堆上。算法为: A,B,C为三个指针光标,其中A,B为

2020-08-11 10:07:40 118

原创 LeetCode菜鸟进化史day2

Day2 周末休息了,补上。 20.Valid Parentheses 给定仅包含字符’(’,’)’,’{’,’}’,’[‘和’]'的字符串,请确定输入字符串是否有效。 输入字符串在以下情况下有效:   1.开括号必须用相同类型的括号封闭;   2.开括号必须以正确的顺序关闭;   3.请注意,空字符串也被视为有效。 分析   将输入的字符串看作字符数组,依次判断输入的左括号有无相应同类型的右括号对应,遍历字符数组后均有同类型括号对应,则输出true,输入空字符串也输出true,只要存在一个没有同类型括号对

2020-08-10 10:04:27 107

原创 LeetCode菜鸟进化史day1

LeetCode day1 按照 Leetcode社区 大佬提供的方法,我决定开始我的Leetcode之旅,在实践中增强自己解决实际问题的能力。 13.Roman to Integer 罗马数字由七个不同的符号表示:I,V,X,L,C,D和M。 符号值 I 1 V 5 X 10 L 50 C 100 D 500 M 1000 例如,两个用罗马数字记为II,仅将两个加在一起。十二写为XII,简称X + II。数字二十七写为XXVII,即XX + V + II。 罗马数字通常从左到右从大到小书写。但是,四

2020-08-07 14:50:56 168

空空如也

空空如也

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

TA关注的人

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