본문 바로가기
반응형

Algorithm17

[Algorithm] Maximum Depth of Binary Tree 01. 문제내용 https://leetcode.com/problems/maximum-depth-of-binary-tree/ Maximum Depth of Binary Tree - LeetCode Can you solve this real interview question? Maximum Depth of Binary Tree - Given the root of a binary tree, return its maximum depth. A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf leetcode.com Given the root of a b.. 2023. 6. 15.
[Algorithm] 이상한 문자 만들기 (5.79ms -> 0.15ms개선) 01. 문제 https://school.programmers.co.kr/learn/courses/30/lessons/12930 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문자열 s는 한 개 이상의 단어로 구성되어 있다. 각 단어는 하나 이상의 공백문자로 구분되어 있고, 각 단어의 짝수번째 알파벳은 대문자로, 홀수번째 알파벳은 소문자로 바꾼 문자열을 리턴하는 함수, solution을 완성하는 문제이다. 02. 문제 풀이로 배운점 이번 문제는 String을 사용하여 풀이하였지만 runtime이 생각보다 오래 걸려서 저번에 사용해봤던 StringBuilde.. 2023. 6. 12.
[Algorithm]3진법 뒤집기(2.87ms -> 0.05ms) 01. 문제내용 https://school.programmers.co.kr/learn/courses/30/lessons/68935 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 02. 문제풀이로 배운점 10진법으로 제공된 수를 3진법으로 바꾼 후 reverse하여 다시 10진법으로 반환하는 알고리즘이다. 초반 풀이에는 stack을 쓰면 유용할 것 같아 Java에서 제공하는 Stack을 사용하여 문제를 풀이하였다. 다른 사람들의 풀이에 StringBuilder가 있어 코드를 개선해보았다. 최대 2.87ms -> 0.05ms 까지 runtime을 개선할 수 .. 2023. 6. 11.
[Algorithm]Two Sum (63ms -> 2ms 개선) 01. 문제내용 https://leetcode.com/problems/two-sum/description/ Two Sum - LeetCode Can you solve this real interview question? Two Sum - Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not leetcode.com Given an array of integers nums and an integer tar.. 2023. 6. 10.
반응형