funmergeTwoSingleLinkedList(l1:ListNode?,l2:ListNode?){// 현재 노드에 대한 참조 변수이다. 연걸 리스트의 모든 노드를 참조하게 된다.varlist1=list1varlist2=list2if(list1==null)returnlist2if(list2==null)returnlist1// 헤드 노드의 참조를 그대로 유지하는 노드 변수이다.valhead=ListNode(0)// 새로운 연결 리스트를 만들어나가기 위한 노드 변수이다.varcurrent:ListNode?=head// 연결 리스트1과 연결 리스트2의 모든 노드를 탐색한다.// 두 연결 리스트에 대해 현재 노드가 null이 아닌 경우 탐색을 계속 수행한다.// 하나라도 null인 경우 탐색을 종료한다.while(list1!=null&&list2!=null){// 각 노드를 비교하여 작은 노드를 새로운 연결 리스트의 노드로 추가한다.if(list1.`val`<=list2.`val`){current?.next=list1// 노드 참조를 그다음 노드로 변경한다.list1=list1.next}else{current?.next=list2list2=list2.next}current=current?.next}// 마지막 노드를 처리한다.// null이 아닌 노드를 마지막 노드로 연결한다.current?.next=list1?:list2returnhead.next}
오픈텔레메트리 API를 사용하여 수동 계측을 통해 트레이스 데이터를 생성하고 사용자화 할 수 있다. 오픈텔레메트리의 API에서 트레이스 시그널과 관련된 인터페이스는 다음과 같다.
트레이서 프로바이더 (tracer provider): API의 엔트리포인트이다. 트레이서에 대한 ...
투 포인터(two pointers) 기법이란 배열과 리스트 같은 선형(linear) 자료 구조에서 데이터를 순차적으로 탐색하는데 사용되는 방법 중 하나이다. 투 포인터 기법은 간단한 방법으로 알고리즘의 성능을 높이는데 주로 사용된다. 문제 해결 시 브루트 포스(brute-force...
컬렉션(collection)이란 데이터(요소)를 그룹화한 것으로 추상 자료형(ADT, abstract data type)을 의미하며, 자료 구조의 구체적인 구현을 규정 짓지는 않는다. 일반적으로 컬렉션의 예로는 리스트(list), 셋(set), 큐(queue), 스택(stack),...
Comments