LeetCode单排日记】的更多相关文章

初衷 之前有研究过一段时间数据结构与算法,但平时使用的不多,就连排序都很少用(自从JDK8有了Stream,就再也没有手写排序了.),所谓用进废退,时至今日,能记住的已经不多了,还记得之前有一次面试,面试官要求写一个快速排序,结果突然记不起来该怎么写了,于是交了一个插入排序... 为了在数据结构与算法方面不至于太辣鸡,特此开一个坑,每天刷一刷LeetCode上的算法题,也顺便把相关的数据结构和算法做一个复习. 如果你也刚好有兴趣一起学习的话,那在这条路上,我能与你作伴. 关于LeetCode L…
2017/11/22 Leetcode 日记 136. Single Number Given an array of integers, every element appears twice except for one. Find that single one. class Solution { public: int singleNumber(vector<int>& nums) { int len = nums.size(); ]; ; i < len; i++){…
2017/11/21 Leetcode 日记 496. Next Greater Element I You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corresponding places of nums2.…
2017/11/13 Leetcode 日记 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 surro…
2017/11/14 Leetcode 日记 442. Find All Duplicates in an Array Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements that appear twice in this array. Could you do it withou…
2017/11/9 Leetcode 日记 566. Reshape the Matrix In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data. You're given a matrix represented by a two-dimensiona…
2017/11/7 Leetcode 日记 669. Trim a Binary Search Tree Given a binary search tree and the lowest and highest boundaries as L and R, 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 re…
2017/11/6 Leetcode 日记 344. Reverse String Write a function that takes a string as input and returns the string reversed. class Solution { public: string reverseString(string s) { , sz = s.size()-; ; i < sz; i++, sz--){ char temp = s[i]; s[i] = s[sz];…
2017/11/5 Leetcode 日记 476. Number Complement Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: The given integer is guaranteed to fit within the range of a 32-bit s…
2017/11/3 Leetcode 日记 654. Maximum Binary Tree Given an integer array with no duplicates. A maximum tree building on this array is defined as follow: The root is the maximum number in the array.(根节点是数组中的最大值) The left subtree is the maximum tree const…