LeetCode
is.lizhichao
这个作者很懒,什么都没留下…
展开
-
LeetCode专题——树
LeetCode专题——树一、前提正如一句老话所说——磨刀不误砍柴功,在为面试或者复试准备算法题的时候,尽量先不要直接钢,直接钢的后果就是刷题进度缓慢,没有多大效果。本人目前觉得较好的一个方法是一个个专题的刷,先根据专题刷一些简单或中等难度的题目,熟悉或者背诵相关模板,在能力达到一定级别后,去刷一刷周赛,随机做一做题目。那么为什么我本次算法复习之路从树这一专题刷起,主要是如下考虑:树的结构可以用链表或线性表的方式保存,这样我们先开始刷 树专题,等于可以复习链表和线性表的一些知识点。一些算法,比原创 2020-07-19 21:56:11 · 287 阅读 · 0 评论 -
1441. Build an Array With Stack Operations
Build an Array With Stack OperationsGiven an array target and an integer n. In each iteration, you will read a number from list = {1,2,3..., n}.Build the target array using the following operations:Push: Read a new element from the beginning list, and原创 2020-05-27 14:54:48 · 265 阅读 · 0 评论 -
1403. Minimum Subsequence in Non-Increasing Order
Minimum Subsequence in Non-Increasing OrderGiven the array nums, obtain a subsequence of the array whose sum of elements is strictly greater than the sum of the non included elements in such subseque...原创 2020-04-23 10:10:51 · 262 阅读 · 0 评论 -
1370. Increasing Decreasing String
Increasing Decreasing StringGiven 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 characte...原创 2020-04-23 00:26:33 · 265 阅读 · 0 评论 -
7. Reverse Integer
Reverse IntegerGiven a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21Note:Assume we a...原创 2020-04-17 20:25:02 · 132 阅读 · 0 评论 -
1. Two Sum——C++和Go语言解法
1.Two SumGiven an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use ...原创 2020-04-10 10:59:36 · 148 阅读 · 0 评论 -
543. Diameter of Binary Tree
543. Diameter of Binary Tree题目: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 ...原创 2019-11-01 12:31:50 · 178 阅读 · 0 评论 -
451. Sort Characters By Frequency
451. Sort Characters By FrequencyGiven a string, sort it in decreasing order based on the frequency of characters.Example 1:Input:“tree” Output:“eert” Explanation:‘e’ appears twice while ‘r...原创 2019-10-28 09:08:26 · 123 阅读 · 0 评论 -
304. Range Sum Query 2D - Immutable
304. Range Sum Query 2D - ImmutableQS:Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2)....原创 2019-10-20 11:09:11 · 116 阅读 · 0 评论 -
115. Distinct Subsequences
115. Distinct Subsequences题目描述:Given a string S and a string T, count the number of distinct subsequences of S which equals T.A subsequence of a string is a new string which is formed from the orig...原创 2019-10-20 09:33:00 · 114 阅读 · 0 评论 -
260. Single Number III
文章目录[260. Single Number III](https://leetcode.com/problems/single-number-iii/)260. Single Number IIIGiven an array of numbers nums, in which exactly two elements appear only once and all the other e...原创 2019-09-16 09:37:57 · 99 阅读 · 0 评论 -
136. Single Number
136. Single NumberQS:Given a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you im...原创 2019-09-15 22:44:15 · 80 阅读 · 0 评论 -
LeetCode 268. Missing Number
文章目录268. Missing NumberAS1:(Brute Force)AS2:AS3:小结:268. Missing NumberQS:Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array.Examp...原创 2019-09-15 10:33:56 · 174 阅读 · 0 评论