Skip to content

Instantly share code, notes, and snippets.

View diegozeng's full-sized avatar
🎯
Focusing

diegozeng

🎯
Focusing
View GitHub Profile
package Test;
import java.util.*;
public class Solution {
public List<List<Integer>> combinationSum2(int[] num, int target) {
List<List<Integer>> res = new ArrayList<List<Integer>>();
if(num.length == 0 || num == null)
return res;
Arrays.sort(num);
helper(num, target, 0, new ArrayList<Integer>(), res);
@diegozeng
diegozeng / ReferenceConfig
Created August 22, 2014 02:58
Dubbo框架中利用ReferenceConfig类的init方法调用Protocol(Dubbo/Hessian/Injvm/Rmi/Webservice)的refer方法生成Invoker实例.
/*
* Copyright 1999-2011 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* 1.2 Implement a function void reverse(char* str) in C or C++ which reverses a null-terminated string.
*
* 思路:申明两个指针,分别指向字符串首尾地址,每一次循环后:首指针和尾指针分别后移和前移一位;一个reverse函数,替换两指针对应的数值.
* 特殊情况: 考虑了空指针.
*/
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
/*
* 1.1 Implement an algorithm to determine if a string has all unique characters
* What if you cannot use additional data structures?
*
* 思路:假设输入是ascii字符,创建一个长度为256的array,遍历输入的字符串,若重复返回false,不重复返回true.
* 特殊情况: null和空字符串都认为是unique的输入,即返回true.输入的字符串长度大于256,返回false.
*/
import java.io.*;
class UniqueCharacters {