上一页 1 2 3 4 5 6 7 ··· 43 下一页

2020年12月6日

215. Kth Largest Element in an Array(partition逆序排序,index+1 == k)

摘要: Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Example 阅读全文

posted @ 2020-12-06 15:06 wsw_seu 阅读(117) 评论(0) 推荐(0) 编辑

220. Contains Duplicate III(核心:set数组有序/桶排序)

摘要: Given an array of integers, find out whether there are two distinct indices i and j in the array such that the absolute difference between nums[i] and 阅读全文

posted @ 2020-12-06 11:51 wsw_seu 阅读(85) 评论(0) 推荐(0) 编辑

2020年12月2日

leetcode 772 基本计算器III(包含+-*/ 以及括号) 核心在于递归

摘要: 现基本计算器以计算简单表达式字符串。 表达式字符串可以包含左括号(和右括号)、加号+或减号、非负整数和空格。 表达式字符串只包含非负整数、+、-、*、/运算符、左括号和空格。整数除法应该截断为零。 您可以假定给定的表达式总是有效的。所有中间结果将在范围内[-2147483648,2147483647 阅读全文

posted @ 2020-12-02 20:22 wsw_seu 阅读(716) 评论(0) 推荐(0) 编辑

227. Basic Calculator II(重点记录上一个符号,每次判断上一个符号)

摘要: Given a string s which represents an expression, evaluate this expression and return its value. The integer division should truncate toward zero. Exam 阅读全文

posted @ 2020-12-02 20:06 wsw_seu 阅读(110) 评论(0) 推荐(0) 编辑

c++ 去字符串两边的空格

摘要: void trim(string &s) { if (s.empty()) { return ; } s.erase(0,s.find_first_not_of(" ")); s.erase(s.find_last_not_of(" ") + 1); } find_first_not_of()与fi 阅读全文

posted @ 2020-12-02 20:05 wsw_seu 阅读(331) 评论(0) 推荐(0) 编辑

2020年11月29日

236. 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 lowes 阅读全文

posted @ 2020-11-29 17:39 wsw_seu 阅读(62) 评论(0) 推荐(0) 编辑

237. Delete Node in a Linked List

摘要: Write a function to delete a node in a singly-linked list. You will not be given access to the head of the list, instead you will be given access to t 阅读全文

posted @ 2020-11-29 16:43 wsw_seu 阅读(52) 评论(0) 推荐(0) 编辑

238. Product of Array Except Self

摘要: Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except n 阅读全文

posted @ 2020-11-29 16:25 wsw_seu 阅读(39) 评论(0) 推荐(0) 编辑

2020年11月22日

单调队列 Monotonic Queue应用:leetcode(未完待续)

摘要: 239. Sliding Window Maximum 581: https://leetcode.com/problems/shortest-unsorted-continuous-subarray/ 862: https://leetcode.com/problems/shortest-suba 阅读全文

posted @ 2020-11-22 15:32 wsw_seu 阅读(149) 评论(0) 推荐(0) 编辑

240. Search a 2D Matrix II

摘要: Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted i 阅读全文

posted @ 2020-11-22 10:23 wsw_seu 阅读(171) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 ··· 43 下一页

导航