题目描述:
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.
Example ...
最后更新于 .
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.
Example ...
最后更新于 .
LeetCode 337. House Robber III
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent ...
最后更新于 .
使用泛型的冒泡排序Java代码:
public class SortUtils {
public static <T extends Comparable<? super T>> void bubbleSort(T[] nums) {
int size = nums.length;
for (int k = 0; k < size; k++) {
for (int i = 0; i + k + 1 < size; i++) {
if (nums[i ...
最后更新于 .
LeetCode 336. Palindrome Pairs
Given a list of unique words. Find all pairs of indices (i, j)
in the given list, so that the concatenation of the two words, i.e. words[i] + words[j]
is a palindrome.
Example ...
最后更新于 .
首先来看笔者遇到的一道面试题,阅读下面的代码并给出执行结果:
class Singleton {
private static Singleton singleton = new Singleton();
public static int counter1;
public static int counter2 = 0;
private Singleton() {
counter1++;
counter2++;
}
public static Singleton getInstance() {
return singleton;
}
}
public class TestSingleton {
public static void main(String[] args) {
Singleton s ...