목록C (16)
고양이와 코딩
연결리스트 문제! 역시 꾸준히 하지 않으니까 매번 새롭게 느껴진다 .. 다시 열심히.. ~ Input: l1 = [2,4,3], l2 = [5,6,4]Output: [7,0,8]Explanation: 342 + 465 = 807.Example 2:Input: l1 = [0], l2 = [0]Output: [0]Example 3:Input: l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9]Output: [8,9,9,9,0,0,0,1] Constraints:The number of nodes in each linked list is in the range [1, 100].0 It is guaranteed that the list represents a number that does not h..
MutexSemaphore1. One thread2. Locked / unlocked3. Locking Mechanism1. Multiple thread2. Count3. Signally 세마포어는 자원의 개수 또는 작업 순서를 제어하기 위한 동기화 도구입니다.세마포어의 본질 : 숫자 카운터- 동작 흐름처음 세마포어 값 = 0 (버퍼 비어있음)1. 소비자가 wait()호출 -> 값이 0이니까 sleep2. 생산자가 데이터를 버퍼에 넣고 post() -> 값이 0에서 1이 됨3. sleep상태의 소비자가 깨어남 -> 값이 1에서 0 (버퍼에서 꺼내서 소비) 세마포어는 소유 개념이 X누가 wait했는지 상관 없이 다른 스레드가 post 해도 됨 뮤텍스는 공유 자원에 동시에 접근하지 못하도록 보호하는 Lock..
1. 모음 제거#include #include #include char* solution(const char* my_string) { char vowels[] = {'a', 'e', 'i', 'o', 'u'}; int str_len = strlen(my_string); char* answer = (char*)malloc(str_len + 1); int idx = 0; for(int i = 0; i vowels 는 배열로 선언. answer는 얼마가 될 지 모르는 문자열을 동적으로 할당하는것이므로 포인터가 필요!str_len + 1은 문자열 뒤 '\0' 공백이 차지하는 자리를 고려한것 2. 배열의 평균값 #include #include #include // number..
연결리스트 문제는,, 첨 풀어봐서 ~ 검색해보고 아이디어를 얻어서 힘겹게 ㄱ ㅡ풀어냈다(이게 easy라니 이게easy라니 이게easy라니 죽자) You are given the heads of two sorted linked lists list1 and list2.Merge the two lists into one sorted list. The list should be made by splicing together the nodes of the first two lists.Return the head of the merged linked listInput: list1 = [1,2,4], list2 = [1,3,4]Output: [1,1,2,3,4,4]Example 2:Input: list1 = [], ..
프로그래머스에서 풀었었던 괄호문제! Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same type of brackets.Open brackets must be closed in the correct order.Every close bracket has a corresponding open bracket of the same type. Example 1:Input: s = "()"Output: trueExample 2:Inpu..
14. Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1:Input: strs = ["flower","flow","flight"]Output: "fl"Example 2:Input: strs = ["dog","racecar","car"]Output: ""Explanation: There is no common prefix among the input strings. Constraints:1 0 strs[i] consists of only lower..