Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- SQL
- sorting
- Tree
- 코테
- simulation
- java
- 코딩테스트
- 구현
- array
- database
- greedy
- Method
- 자바
- string
- geometry
- implement
- hash table
- Binary Search
- Class
- Binary Tree
- Data Structure
- Number Theory
- Stack
- Math
- Matrix
- dynamic programming
- Counting
- 파이썬
- bit manipulation
- two pointers
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 674. Longest Continuous Increasing Subsequence 본문
1. Input
1) int[] nums
2. Output
1) nums에서 오름차순인 부분배열 중 그 길이가 가장 긴 것의 길이를 반환
- 부분배열은 연속적이어야 한다.
- 오름차순이기 때문에 i<j라면 nums[i]<nums[j]여야 한다.
3. Constraint
1) 1 <= nums.length <= 10^4
2) - 10^9 <= nums[i] <= 10^9
4. Example
Input: nums = [1,3,5,4,7] -> Output: 3
설명: 가장 긴 부분배열은 [1,3,5]이다. [1,3,5,7]은 불연속적이기 때문에 답이 될 수 없다.
5. Code
1) 첫 코드(2023/03/13)
int answer = 1;
for(int i=0 ; i<nums.length-1 ; i++){
int len = 1;
for(int j=i+1 ; j<nums.length ; j++){
if(nums[j-1]<nums[j]) len++;
else break;
}
if(len>answer) answer = len;
}
return answer;
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 2535. Difference Between Element Sum and Digit Sum of an Array (0) | 2023.03.13 |
---|---|
[LeetCode/Medium] 677. Map Sum Pairs (0) | 2023.03.13 |
[LeetCode/Easy] 2586. Count the Number of Vowel Strings in Range (0) | 2023.03.13 |
[LeetCode/Easy] 2544. Alternating Digit Sum (0) | 2023.03.10 |
[LeetCode/Easy] 645. Set Mismatch (0) | 2023.03.10 |