Given the sorted rotated arraynumsof unique elements, returnthe minimum element of this array. You must write an algorithm that runs inO(log n) time. Example 1: Input: nums = [3,4,5,1,2] Output: 1 Explanation: The original array was [1,2,3,4,5] rotated 3 times. Example 2: I...
Find Peak Element 一.题目链接:https://leetcode.com/problems/find-peak-element/二.题目大意:给定一个长度为N的一维数组,数组是无序的,要求找到数组中的极大值(或局部最大值),并返回该极大值的下标,并假设 nums[-1] = nums[n] = -∞.;当某元素同时大于它两边的元素时,则该元素是数组中的一个极大...
classSolution{public:intremoveDuplicates(vector<int>&nums){unordered_set<int>uniqueSet;// 使用unordered_set来存储不重复的元素for(int i=0;i<nums.size();i++){if(uniqueSet.find(nums[i])==uniqueSet.end()){uniqueSet.insert(nums[i]);}}cout<<uniqueSet.length();for(int i=0;i<uniqueSet....
169. Majority Element (多数元素), Easy, 1089 likes 234. Palindrome Linked List (回文链表), Easy, 1072 likes 62. Unique Paths (不同路径), Medium, 1072 likes 189. Rotate Array (旋转数组), Medium, 1057 likes 94. Binary Tree Inorder Traversal (二叉树的中序遍历), Easy, 1052 likes 56. ...
如果你是纯小白,建议一上来先刷刷前200中的Easy题,从Two Sum开始,找找感觉,后续再按照标签分类刷...
//最长公共子串 // int main() // { // vector<string> strs={{"adfgh"},{"adfvbg"},{"adcv"}}; // if(strs.empty()) // return 0; // const auto p=minmax_element(strs.begin(),strs.end()); // for(int i=0;i<p.first->size();++i) // { // if(p.first->at(i)...
1304 Find N Unique Integers Sum up to Zero 77.10% Easy 1303 Find the Team Size * $ 90.80% Easy 1302 Deepest Leaves Sum 86.90% Medium 1301 Number of Paths with Max Score 38.70% Hard 1300 Sum of Mutated Array Closest to Target 43.10% Medium 1299 Replace Elements with Greatest Element on ...
34 find-first-and-last-position-of-element-in-sorted-array 📝 Medium 35 search-insert-position 📝 Easy 36 valid-sudoku 📝 Medium 37 sudoku-solver 📝 Hard 38 count-and-say 📝 Medium 39 combination-sum 📝 Medium 40 combination-sum-ii 📝 Medium 41 first-missing-positive 📝 Hard...
LeetCode 652. Find Duplicate Subtrees: LeetCode 290. Word Pattern: LeetCode 554. Brick Wall: LeetCode 149. Max Points on a Line: LeetCode 355. Design Twitter: LeetCode 128. Longest Consecutive Sequence: 11.贪心 LeetCode 860. Lemonade Change ...
LeetCode 刷题随手记 - 第一部分 前 256 题(非会员),仅算法题,的吐槽 https://leetcode.com/problemset/algorithms/...