![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/89953083ae6687f7ec9a58e76adce442.png)
class Solution {
public int search(int[] nums, int target) {
int n = nums.length;
if(n == 0)
return -1;
if(n == 1)
return nums[0] == target ? 0 : -1;
int l = 0 , r = n - 1;
while(l <= r){
int mid = (l+r)/2;
if(nums[mid] == target){
return mid;
}
if(nums[0] > nums[mid]){
if(nums[mid]<target && target <= nums[n-1]){
l = mid + 1;
}else{
r = mid - 1;
}
}else{
if(target < nums[mid] && target>=nums[0]){
r = mid - 1;
}else{
l = mid + 1;
}
}
}
return -1;
}
}
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/395bccbfd02a12a061f0483e5e36e28a.png)
class Solution {
public int maxArea(int[] height) {
int l = 0 , r = height.length-1;
int maxArea = (r-l) * Math.min(height[l] , height[r]);
while(l<r){
if(height[l]<height[r]){
l++;
}else{
r--;
}
maxArea = Math.max(maxArea , (r-l)*Math.min(height[l],height[r]));
}
return maxArea;
}
}
class Solution {
public int maxArea(int[] height) {
int l = 0 , r = height.length-1 , maxArea = 0;
while(l<r){
maxArea = height[l] > height[r] ? Math.max(maxArea , (r-l)*height[r--]) : Math.max(maxArea , (r-l)*height[l++]);
}
return maxArea;
}
}
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/f3fa45eb820d87b4669c26a4330d0467.png)
class Solution {
public List<List<Integer>> permute(int[] nums) {
int len = nums.length;
List<List<Integer>> res = new ArrayList<List<Integer>>();
Deque<Integer> path = new ArrayDeque<>(len);
boolean[] isUsed = new boolean[len];
dfs(res , path , nums , isUsed , 0 , len);
return res;
}
public void dfs(List<List<Integer>> list , Deque<Integer> path ,int[] nums, boolean[] isUsed ,int depth , int len){
if(depth==len){
list.add(new ArrayList<Integer>(path));
return;
}
for(int i=0 ; i<len ; i++){
if(!isUsed[i]){
path.addLast(nums[i]);
isUsed[i] = true;
dfs(list , path , nums , isUsed , depth+1 , len);
isUsed[i] = false;
path.removeLast();
}
}
}
}