
LeetCode
MingjaLee
这个作者很懒,什么都没留下…
展开
-
LeetCode - Permutations II
题目链接:https://leetcode.com/problems/permutations-ii/Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example, [1,1,2] have the following unique pe原创 2016-04-27 12:42:19 · 511 阅读 · 0 评论 -
LeetCode - Binary Tree Level Order Traversal
这题算是树遍历的基础,写这篇博客主要是为了记录两种代码风格的层序遍历。 Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example: Given binary tree [3,9,20,null,null原创 2016-07-08 22:08:16 · 377 阅读 · 0 评论 -
素数 筛选获取
https://leetcode.com/problems/count-primes/class Solution { public: int countPrimes(int n) { if(n < 2) return 0; vector<bool> flag(n, true); //flag primes flag[0原创 2016-09-16 21:20:43 · 527 阅读 · 0 评论 -
C++ STL map容器的排序(按key或value)
template < class Key, // map::key_type class T, // map::mapped_type class Compare = less<Key>,原创 2016-09-19 22:01:33 · 3644 阅读 · 0 评论 -
经典排序方法实现
冒泡排序 选择排序 插入排序 快速排序 堆排序 希尔排序 归并排序 #include <iostream> #include <string> #include <algorithm> #include <vector> #include <map> #include <unordered_map> #include <string>using namespace std;vector<int> a原创 2016-09-21 00:50:44 · 632 阅读 · 0 评论 -
PriorityQueue<> JAVA
这里简单对其重复的方法做点简单的区分。 offer,add区别: 一些队列有大小限制,因此如果想在一个满的队列中加入一个新项,多出的项就会被拒绝。 这时新的 offer 方法就可以起作用了。它不是对调用 add() 方法抛出一个 unchecked 异常,而只是得到由 offer() 返回的 false。 poll,remove区别: remove() 和 poll() 方法都是从队列中删除原创 2017-02-09 22:46:59 · 525 阅读 · 0 评论