题目 Given an array of size n, find the majority element. The majority element is the element that appears more …
分类:LeetCode
[LeetCode] Shortest Distance from All Buildings 建筑物的最短距离
You want to build a house on an empty land which reaches all buildings in the shortest amount…
LeetCode | Combinations
题目: Given two integers n and k, return all possible combinations of k numbers out of …
LeetCode | Interleaving String
题目: Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 a…
LeetCode | Partition List
题目: Given a linked list and a value x, partition it such that all nodes less than x come before…
LeetCode 073 Set Matrix Zeroes
题目描述 Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. click to sh…
【Leetcode】16. 3Sum Closest 集合中选三个元素之和最接近指定值
1. 题目 Given an array S of n integers, find three integers in S such that the sum is closest to a given number,…
LeetCode543. Diameter of Binary Tree
Solution1 If we think about it, there may be three conditions for the largest diameter of a binary tree. The l…
算法练习--LeetCode--54. Spiral Matrix 100%
Spiral Matrix Medium Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix i…
[剑指offer] 和为S的连续正数序列
本文首发于我的个人博客:尾尾部落 题目描述 小明很喜欢数学,有一天他在做数学作业时,要求计算出9~16的和,他马上就写出了正确答案是100。但是他并不满足于此,他在想究竟有多少种连续的正数序列的和为100(至少包括两个数…
【leetcode】Edit Distance(编辑距离)(动态规划)
1、题目描述 Given two words word1 and word2, find the minimum number of operations required to convert word1 to wor…
2018-07-02 容器.size()与int比较问题
int maxSize = -1; string ss = "hello,world."; if(maxSize < ss.size()) cout << "ss.size()" << en…