topics

全部话题 - 话题: biglist
(共0页)
f*****7
发帖数: 92
1
我个人不喜欢swap的方法,自己没法理解
排序,然后跳过重复元素
希望能帮上你
class Solution {
public:
vector > permuteUnique(vector &num) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
sort(num.begin(), num.end());
int len = num.size();
int* path = (int*) malloc(sizeof(int) * len);
bool* visited = (bool*) malloc(sizeof(int) * len);
memset(visited, false, sizeof(bool) * len);
vector > bigList;
int... 阅读全帖
c*******e
发帖数: 290
2
来自主题: Java版 - 问个 Generic 的问题
List bigList = new ArrayList();
List smallList = new ArrayList()
List newList = ListUtils.subtract(bigList, smallList);
List[] samples = {bigList, newList};
后面两行同样的问题,都 warning 说没有 parametrized. 那个 subtract 是因为
ListUtils 里面只返回 raw type List. 最后那行是因为直接定义数组比较简洁。
这种情况,只有用 @SuppressWarnings 吗?
c*******e
发帖数: 290
3
来自主题: Java版 - 问个 Generic 的问题
奇怪的是,common.apaches library 的一些 utility classes, 都不是用 generics,
所以出现这个 warning. 难道是因为它太老?
http://commons.apache.org/proper/commons-collections/javadocs/a
第二个问题,如果改为:
List[] samples = {bigList, newList};
就出错,提示 “you cannot create a generic array of List”. 可能是因
为这种 syntax ={,,,} 定义一个 primitive array, 其不支持 generics.所以,这种
快捷方式 {} 定义数组,只能使用原始的数据类型。
(共0页)