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
- Real MySQL
- git
- post
- 함수형 코딩
- Jackson
- 뇌정리
- 스터디
- jsp
- 알고리즘
- sqldeveloper
- 성적프로그램
- java
- Python
- 책리뷰
- 회고
- 필기
- 코드숨
- 정보처리기사
- 항해99
- If
- 미니프로젝트
- 2020년 정보처리기사 4회
- 서평
- algorithms
- 주간회고
- Til
- 2020년 일정
- 2020년 제4회 정보처리기사 필기 문제 분석
- LeetCode
- hackerrank
Archives
- Today
- Total
조컴퓨터
35. Search Insert Position 본문
for문을 돌리려고 했으나 for문보다는 인덱스 값 두 개와 조건 하나를 두어서 인덱스 값을 대입해 비교하는 쪽이 식을 세우기에 훨씬 수월했다.
class Solution {
public int searchInsert(int[] nums, int target) {
int i = 0;
int idx = 0;
while( i<nums.length ) {
if( nums[idx] < target ) {
idx++;
}
i++;
}
return idx;
}
}
'LeetCode > Algorithms' 카테고리의 다른 글
58. Length of Last Word (0) | 2021.10.28 |
---|---|
53. Maximum Subarray (0) | 2021.10.27 |
28. Implement strStr() (0) | 2021.10.20 |
27. Remove Element (0) | 2021.10.19 |
26. Remove Duplicates from Sorted Array (0) | 2021.10.17 |