自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 647. Palindromic Substrings

上原题:Given a strings, returnthe number ofpalindromic substringsin it.A string is apalindromewhen it reads the same backward as forward.Asubstringis a contiguous sequence of characters within the string.Example 1:Input: s = "abc"Output...

2021-05-20 15:28:11 78

原创 427. Construct Quad Tree

以下是题目:Given an * nmatrixgridof0'sand1'sonly. We want to represent thegridwith a Quad-Tree.Returnthe root of the Quad-Treerepresenting thegrid.Notice that you can assign the value of a node toTrueorFalsewhenisLeafisFalse, and both ...

2021-05-19 08:31:20 122

原创 1765. Map of Highest Peak

1765.Map of Highest PeakYou are given an integer matrixisWaterof sizem x nthat represents a map oflandandwatercells.IfisWater[i][j] == 0, cell(i, j)is alandcell. IfisWater[i][j] == 1, cell(i, j)is awatercell.You must assign each ce...

2021-04-23 08:54:35 118

原创 900. RLE Iterator

900.RLE Iterator题目如下:Write an iterator that iterates through a run-length encoded sequence.The iterator is initialized byRLEIterator(int[] A), whereAis a run-length encoding of somesequence. More specifically,for all eveni,A[i]tells us the ...

2021-04-21 14:18:05 81

原创 Eclipse设置支持C++20

偶然用到一个C++17的特性,才发现自己只支持C++14的eclipse过时了。现在设置很简单了,直接去下载个最新版的Eclipse CPP版,解压,创建新的Project,然后按图设置即可完成。

2020-11-27 14:07:29 284

原创 1038. Binary Search Tree to Greater Sum Tree, 这个方法好!

Given the root of a binarysearchtree with distinct values, modify it so that everynodehas a new value equal to the sum of the values of the original tree that are greater than or equal tonode.val.As a reminder, abinary search treeis a tree that sa...

2020-07-29 10:12:15 101

原创 219. Contains Duplicate II 两种map的效率

Given an array of integers and an integerk, find out whether there are two distinct indicesiandjin the array such thatnums[i] = nums[j]and theabsolutedifference betweeniandjis at mostk.Example 1:Input: nums = [1,2,3,1], k = 3Output: tru...

2020-06-23 09:15:03 116

原创 205. Isomorphic Strings

Given two stringssandt, determine if they are isomorphic.Two strings are isomorphic if the characters inscan be replaced to gett.All occurrences of a character must be replaced with another character while preserving the order of characters. No t...

2020-06-22 14:46:50 106

原创 687. Longest Univalue Path 递归解法

Given a binary tree, find the length of the longest path where each node in the path has the same value. This path may or may not pass through the root.The length of path between two nodes is represented by the number of edges between them.Example 1:

2020-06-21 13:19:44 123

原创 796. Rotate String小而精致的一道题

We are given two strings,AandB.Ashift onAconsists of taking stringAand moving the leftmost character to the rightmost position. For example, ifA = 'abcde', then it will be'bcdea'after one shift onA. ReturnTrueif and only ifAcan becomeBa...

2020-05-28 09:23:04 206

原创 1422. Maximum Score After Splitting a String题目虽小但是很tricky

Given astringsof zeros and ones,return the maximum score after splitting the string into twonon-emptysubstrings(i.e.leftsubstring andrightsubstring).The score after splitting a string is the number ofzerosin theleftsubstring plus the numbe...

2020-05-22 08:52:40 258

原创 953. Verifying an Alien Dictionary,很少把lambda写的那么复杂

In an alien language, surprisingly they also use english lowercase letters, but possiblyin a differentorder. Theorderof the alphabetis some permutationof lowercase letters.Given a sequence ofwordswritten in the alien language,and theorderof th...

2020-05-21 09:20:52 140

原创 538. Convert BST to Greater Tree,思考方式很重要

Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.Example:Input: The root of a Binary Search Tree like this:

2020-05-21 09:18:14 139

原创 1184. Distance Between Bus Stops 标准库带来的便利

A bushasnstops numbered from0ton - 1that forma circle. We know the distance between all pairs of neighboring stops wheredistance[i]is the distance between the stops numberiand(i + 1) % n.The bus goes along both directionsi.e. clockwise and ...

2020-05-21 09:13:32 128

原创 1029. Two City Scheduling 递归vs找规律

There are2Npeople a company is planning to interview. The cost of flying thei-th person to cityAiscosts[i][0], and the cost of flying thei-th person to cityBiscosts[i][1].Return the minimum cost to fly every person to a city such that exactlyN...

2020-05-20 09:08:00 140

原创 669. Trim a Binary Search Tree, 差点没看懂题目

Given a binary search tree and the lowest and highest boundaries asLandR, trim the tree so that all its elements lies in[L, R](R >= L). You might need to change the root of the tree, so the result should return the new root of the trimmed binary se...

2020-05-09 10:21:28 169

原创 1078. Occurrences After Bigram,有split函数的语言会更好

Given wordsfirstandsecond, consider occurrences in sometextof the form "first second third", wheresecondcomes immediately afterfirst, andthirdcomes immediately aftersecond.For each such o...

2020-05-08 14:59:59 146

原创 463. Island Perimeter

You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water.Grid cells are connected horizontally/vertically (not diagonally). The grid is completely...

2020-05-08 08:51:54 120

原创 893. Groups of Special-Equivalent Strings 思路比较典型的一个题目

You are given an arrayAof strings.AmoveontoSconsists of swapping any two even indexed characters ofS, or any two odd indexed characters ofS.Two stringsSandTarespecial-equivalentif af...

2020-05-07 11:07:22 163

原创 476. Number Complement, 思考三秒选好武器

Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.Example 1:Input: 5Output: 2Explanation: The binary representa...

2020-05-07 09:38:51 142

原创 872. Leaf-Similar Trees 递归真的好用

Consider all the leaves of a binary tree. Fromleft to right order, the values of thoseleaves form aleaf value sequence.For example, in the given tree above, the leaf value sequence is(6, 7, 4...

2020-05-07 09:15:31 111

原创 1030. Matrix Cells in Distance Order, C++新的库函数带来的便利

We are given a matrix withRrows andCcolumns has cells with integer coordinates(r, c), where0 <= r < Rand0 <= c < C.Additionally, we are given a cell in that matrix with coordinat...

2020-05-07 09:04:48 100

原创 1185. Day of the Week 需要知道该怎么计算

Given a date, return the corresponding day of the week for that date.The input is given as three integers representing theday,monthandyearrespectively.Return the answer as one of the following...

2020-05-06 14:16:43 183

原创 1217. Play with Chips 理解你,不容易

There are some chips, and the i-th chip is at positionchips[i].You can perform any of the two following types of movesany number of times(possiblyzero)on any chip:Move thei-th chipby2 unit...

2020-05-06 10:22:30 397

原创 快乐Python快速上手系列10 - 中文编码问题

关于现实中文字符,总会遇到很多问题,比方说在Python2.7中,默认情况,Python对字符的解码时采用ASCII的形式,这也是为什么当我们文件里添加了中文注释,或者字符串里包含了中文字符,python会报错如下:if __name__ == '__main__':s1 = "你好"print(s1)运行后错误信息为:

2017-12-27 15:09:37 282

原创 快乐Python快速上手系列9 - 界面Tkinter编程

这里主要讲讲layout的问题,一般都知道,一是pack,另一个是grid,但是有时候运行时得到的结果并不是自己设计的,这里记录下学习的过程。1. packpack在对齐时, 有LEFT, BOTTOM, RIGHT, TOP,这是对当前的frame说的,如果控件多了,就得增加sub frame来更精细的控制,给个例子。from Tkinter impo

2017-12-27 15:09:10 379

原创 快乐Python快速上手系列8 - 有趣的type函数

用过Java/C++的人,在写python脚本时突然需要enum,然而,Python从version 3.4才开始支持enum,目前项目规定python2.7。搜索下来,发现了type的一个妙用。常见的用法,type(var),返回该变量的type。下面看一个更厉害的用法。type(name, (base), dict)这里的type接收3个参数,第一个参数是类名,第二

2017-12-27 15:08:43 224

原创 快乐Python快速上手系列7 - 动态获得类属性

记得在Java编程中,用过其一个Reflection的特性,也就是,通过class和Instance,获得其指定名称的函数、属性,然后调用修改。这里简单说下python的这项功能。起因是这样的,有如下的类,在程序运行的过程中,需要根据core_N,这里,N取值[0, 1, 2, 3],根据N值的不同,需要向core_N中append数据。class Co

2017-12-27 15:08:19 193

原创 快乐Python快速上手系列5 - Excel文件处理

python中的excel处理,仅代表个人观点,如有错误,欢迎提出改进。

2017-12-27 15:07:10 196

原创 快乐Python快速上手系列4 - UTC与本地时间转换

python时间处理,仅代表个人观点,如有错误,欢迎提出改进。

2017-12-27 15:05:24 1596 1

原创 快乐Python快速上手系列2 - XML文件读写

python基本xml处理操作。

2017-12-27 15:04:21 419

原创 快乐Python快速上手系列1 - CSV操作

python读写csv文件。

2017-12-27 15:02:59 337

原创 快乐Python快速上手系列0 - Python Tips

python开始使用前的若干小技巧积累

2017-12-27 15:01:00 192

空空如也

空空如也

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

TA关注的人

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