Subclasses
Given a collection of numbers, return all possible subclasses.
public class Solution {
public List<List<Integer>> permute(int[] num) {
ArrayList<List<Integer>> result = new ArrayList<List<Integer>>();
ArrayList<Integer> row = null;
if(num == null ||num.length == 0) return result;
long size = (long)Math.pow(2, num.length);
for(long i = 0; i < size; i ++){
row = new ArrayList<Integer>();
for(int j = 0; j < num.length; j ++){
if((i >> j) % 2 == 1) row.add(num[j]);
}
result.add(row);
}
return result;
}
}
Subclasses的更多相关文章
- Core Java Volume I — 5.1. Classes, Superclasses, and Subclasses
5.1. Classes, Superclasses, and SubclassesLet's return to the Employee class that we discussed in th ...
- Class hierarchy of UIResponder as well as subclasses of UIView and UIControl
When you were dragging in your label and your button to this view, you were adding them as subviews. ...
- The third column indicates whether subclasses of the class declared outside this package have access to the member.;
总结1.modifier 改性剂 修饰符 修饰语 调节器access modifier 访问修饰符 存取权限 存取修饰词 存取修饰字官网“can”Access level modifiers dete ...
- Comparing Data-Independent Acquisition and Parallel Reaction Monitoring in Their Abilities To Differentiate High-Density Lipoprotein Subclasses 比较DIA和PRM区分高密度脂蛋白亚类的能力 (解读人:陈凌云)
文献名:Comparing Data-Independent Acquisition and Parallel Reaction Monitoring in Their Abilities To Di ...
- 虾扯蛋:Android View动画 Animation不完全解析
本文结合一些周知的概念和源码片段,对View动画的工作原理进行挖掘和分析.以下不是对源码一丝不苟的分析过程,只是以搞清楚Animation的执行过程.如何被周期性调用为目标粗略分析下相关方法的执行细节 ...
- [BOT] 一种android中实现“圆角矩形”的方法
内容简介 文章介绍ImageView(方法也可以应用到其它View)圆角矩形(包括圆形)的一种实现方式,四个角可以分别指定为圆角.思路是利用"Xfermode + Path"来进行 ...
- ThreadLocal简单理解
在java开源项目的代码中看到一个类里ThreadLocal的属性: private static ThreadLocal<Boolean> clientMode = new Thread ...
- Python高手之路【三】python基础之函数
基本数据类型补充: set 是一个无序且不重复的元素集合 class set(object): """ set() -> new empty set object ...
- 多线程爬坑之路-Thread和Runable源码解析
多线程:(百度百科借一波定义) 多线程(英语:multithreading),是指从软件或者硬件上实现多个线程并发执行的技术.具有多线程能力的计算机因有硬件支持而能够在同一时间执行多于一个线程,进而提 ...
随机推荐
- 安装boost1.57.0__注意之前mgiza似乎因为boost没有安装也没有完全编译成功
首先下载(废话) 解压, ./bootstrap.sh 之后在运行b2 ./b2 -j8 --prefix=$PWD --libdir=$PWD/lib64 --layout=system link= ...
- C扩展 从共享内存shm到memcache外部内存
引言 - ipc - shm 共享内存 本文会通过案例了解ipc 的共享内存机制使用, 后面会讲解C 如何使用外部内存服务memcached. 好先开始了解 linux 共享内存机制. 推荐先参看下面 ...
- Why string is immutable in Java ?
This is an old yet still popular question. There are multiple reasons that String is designed to be ...
- hdu 2094 产生冠军
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2094 产生冠军 Description 有一群人,打乒乓球比赛,两两捉对撕杀,每两个人之间最多打一场比 ...
- hdu 1277 全文检索
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1277 全文检索 Description 我们大家经常用google检索信息,但是检索信息的程序是很困难 ...
- 【Masonry】使用技巧 - 篇一
从别人项目得到的灵感 : 请看以下代码 UIColor *darkColor = [UIColor colorWithHexString:@"0x28303b"]; // 1. 确 ...
- spring mvc官网下最新jar搭建框架-静态资源访问处理-注解-自动扫描
1.从官网下载spring相关jar http://spring.io/projects 点击SPRING FRAMEWORK
- using详解(C#)
using肯定所有人都用过,最简单的就是使用using引入命名空间,然后就是引入别名,简化输入,本文主要介绍第三种用法,即用using强制对象清理资源. 先看下面这段代码: try { using ( ...
- Chrome控制台输入多行js
Chrome控制台输入多行js 分类: chrome2013-09-08 09:40 342人阅读 评论(0) 收藏 举报 控制台 Chrome控制台中回车默认是执行,要想输入换行,应按Enter+S ...
- token验证-微信公众平台开发3(asp.net)
童鞋们直接看代码吧:(我这里是ashx处理程序写的类,开发过网站的一般都知道) <%@ WebHandler Language="C#" class="weixin ...