674.最长连续递增序列
这题我果断超时,搞得我做简单题都没信心了😢
class Solution {
public int findLengthOfLCIS(int[] nums) {
int max=1;
for(int i=0;i
int j=i;
while(j
if(nums[j+1]>nums[j])
j++;
}
max=max>(j-i+1)?max:(j-i+1);
i=j+1;
}
return max;
}
}
以下为答案。
class Solution {
public int findLengthOfLCIS(int[] nums) {
int max=1,start=0;
for(int end=1;end
if(nums[end]<=nums[end-1])
start=end;
max=Math.max(max,end-start+1);
}
return max;
}
}
160.相交链表
简单题我还是不会😓
我的Java不是要挂了吧,救命🆘
public class Solution {
public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
if (headA == null || headB == null) {
return null;
}
ListNode pA = headA, pB = headB;
while (pA != pB) {
pA = pA == null ? headB : pA.next;
pB = pB == null ? headA : pB.next;
}
return pA;
}
}