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 |
Tags
- hackerrank
- 알고리즘
- 책리뷰
- Til
- 미니프로젝트
- 정보처리기사
- 함수형 코딩
- Real MySQL
- 회고
- 스터디
- 2020년 정보처리기사 4회
- If
- sqldeveloper
- algorithms
- 항해99
- Jackson
- 2020년 제4회 정보처리기사 필기 문제 분석
- 성적프로그램
- 코드숨
- 뇌정리
- git
- java
- 서평
- jsp
- Python
- post
- LeetCode
- 필기
- 주간회고
- 2020년 일정
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 |