목록Coding (23)
코딩 공부

[LeetCode] [Easy] 383. Ransome Note leetcode.com/problems/ransom-note/ Ransom Note - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Ransome Note 잡지에서 나온 글자를 이용해서 노트를 만드는 문제에요. 잡지니까 한글자에 한번씩만 사용할 수 있겠네요. HashMap을 사용해서 갯수를 구하고 그 갯수를 비교하는 방법으로 풀었어요. 역시나 느립니다ㅠㅠ 알파벳 사이즈가 26인걸 이용해서 갯수를 ..

[LeetCode] [Easy] 203. Remove Linked List Elements leetcode.com/problems/remove-linked-list-elements/ Remove Linked List Elements - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 연결된 리스트 특정 노드 삭제하기 이렇게 연결되어있을때 주어진 값을 가진 노드를 지우고 맨 앞에 노드를 리턴하면 됩니다. 저는 앞쪽 노드를 저장해두면서 같은 숫자가 나올때 현재 노드를..

[LeetCode] [Easy] 242. Valid Anagram leetcode.com/problems/valid-anagram/ Valid Anagram - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Anagram 확인하기 문자열안에 있는 문자들이 순서가 바껴서 나오는 문자열이 Anagram이라고 한대요. 소문자로만 이루어져있다고 해서 길이 26인 배열을 만들어서 카운트해주고 그 갯수를 비교해줬어요. 그럭 저럭한 속도네요. 배열 길이를 늘려서 계산을 줄여..

[LeetCode] [Easy] 205. Isomorphic Strings leetcode.com/problems/isomorphic-strings/ Isomorphic Strings - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 같은 구조 문자열 찾기 egg와 add를 비교했을때 e -> a, g ->d로 인식해서 같은 구조를 이루기 때문에 true를 리턴하고, f -> b, o ->a이지만 r로도 나올수 있기때문에 같은 구조가 아니라 false를 리턴합니..

[LeetCode] [Easy] 1417. Reformat The String leetcode.com/problems/reformat-the-string/ Reformat The String - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문자열 변경하기 문자열속에 나온 문자와 숫자를 번갈아가면서 나오도록 바꿔서 리턴하는게 문제에요. 조합이 나올수 없다면 빈 문자열을 리턴해주세요. 문자열에 있는 문자와 숫자를 나눠서 저장해두고 길이가 2 이상 차이나면 맞는 조..

[LeetCode] [Easy] 693. Binary Number with Alternating Bits leetcode.com/problems/binary-number-with-alternating-bits/ Binary Number with Alternating Bits - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 이진수 매번 0, 1 바뀌는지 확인하기 이진수로 변환했을때 인접한 두 수가 같지 않는지 확인하는 함수를 만드는 문제에요. 예를들어 5는 이진..

[LeetCode] [Easy] 1464. Maximum Product of Two Elements in an Array leetcode.com/problems/maximum-product-of-two-elements-in-an-array/ Maximum Product of Two Elements in an Array - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 배열 안 가장 큰 두수 곱하기 작은수부터 큰수로 정렬해서 마지막 두 수를 곱하면 될것 같아요. ..

[LeetCode] [Easy] 1572. Matrix Diagonal Sum leetcode.com/problems/matrix-diagonal-sum/ Matrix Diagonal Sum - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 2D 대각선 합 구하기 쉽게 생각할수 있는건 nested for loop을 돌려서 각각의 위치를 더해주는건데 생각보다 더 복잡해 질것 같아요. 그래서 한번의 for loop으로도 합을 구하는 방법을 찾아봤어요. 대각선은 항상..

[LeetCode] [Easy] 1389. Create Target Array in the Given Order leetcode.com/problems/create-target-array-in-the-given-order/ Create Target Array in the Given Order - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 주어진 숫자 배열을 주어진 인댁스 자리에 넣기 같은 인댁스에 넣을경우 기존에 있던 숫자는 오른쪽으로 밀려야해요. List에..

[LeetCode] [Easy] 1528. Shuffle String leetcode.com/problems/shuffle-string/ Shuffle String - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문자열 셔플 주어진 인텍스 배열과 문자열을 가지고 아래 두줄의 결과값을 구하는 문제에요. 캐릭터 배열에 자리에 맞는 캐릭터를 넣고 마지막에 문자열로 바꿔서 리턴