674
代码
class Solution {
public int findLengthOfLCIS(int[] nums) {
// int max=1;
// int start =0;
// if(nums.length<1){
// return 0;
// }
// for(int i=1;i<nums.length;i++){
// if(nums[i]>nums[i-1]){
// max=Math.max(max,i-start+1);
// }else{
// start=i;
// }
// }
// return max;
int count=1;
int res=1;
for(int i=0;i<nums.length-1;i++){
if(nums[i+1]>nums[i]){
count++;
}else{
count=1;
}
res=Math.max(res,count);
}
return res;
}
}
1952
给你一个整数 n 。如果 n 恰好有三个正除数 ,返回 true ;否则,返回 false 。
思路 看这个数能不能被三个数整数即可,模运算
代码
class Solution {
//判断1-n之间能被n整除的数字的个数为3即可
public boolean isThree(int n) {
int count=0;
for(int i=1;i<=n;i++){
if(n%i==0){
count++;
}
if(count>3){
return false;
}
}
if(count==3){
return true;
}
return false;
}
}