LeetCode 14

[LeetCode] #26. Remove Duplicates from Sorted Array (reapeat : 0)

문제를 제대로 안읽고 풀엇더니 오래걸렸다. non-decreasing order는 오름차순이라는 뜻이고 , 중복 값을 제거한 배열의 길이를 반환하는 문제이다. Description Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same. Then return the number of unique elements in nums. Consider the number of unique elements of nums..

[LeetCode] #27. Remove Element (repeat : 0)

지정된 배열의 요소를 삭제하는 문제이다. 배열의 인덱스만 변경해 간단하게 풀었다. Description Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The order of the elements may be changed. Then return the number of elements in nums which are not equal to val. Consider the number of elements in nums which are not equal to val be k, to get accepted, you need to do the following things: Chan..

[LeetCode] #88. Merge Sorted Array (repeat : 0)

두 개의 배열을 합치고 , 오름차순 정렬로 반환하는 문제이다. sort 메소드를 사용해서 간단히 해결했다. # Description You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively. Merge nums1 and nums2 into a single array sorted in non-decreasing order. The final sorted array should not be returned by the function, but instea..

[LeetCode] #1290 Convert Binary Number in a Linked List to Integer (repeat : 0)

LinkedList의 노드에는 이진수로만 이루어져있으며, 이를 십진수로 바꾸는 문제이다. Description Given head which is a reference node to a singly-linked list. The value of each node in the linked list is either 0 or 1. The linked list holds the binary representation of a number. Return the decimal value of the number in the linked list. The most significant bit is at the head of the linked list. Example 1: Input: head = [1,0,1] O..

[LeetCode] #83 Remove Duplicates from Sorted List (repeat : 0)

중복값이 나오면 포인터를 리스트에서 빼는 문제이다. 요소를 Set 자료구조에 넣은 후,Set자료구조에 포함되면 이전포인터가 현재포인터를 건너띄고 다음포인터를 향하도록 하였다. 자바인데 컴파일러를 C로 했더니 계속 오류가 낫다 -- # Description Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well. Example 1: Input: head = [1,1,2] Output: [1,2] Example 2: Input: head = [1,1,2,3,3] Output: [1,2,3] #Solution cl..