This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * 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 { |