본문 바로가기

반응형
SMALL

LeetCode

263. Ugly Number 유명한 못 생긴 수입니다. 원래 유명한 문제인 못 생긴 수는 이 문제가 아니죠. 약간... 빌드업을 위한? 문제라고 생각하시면 될 거 같습니다. 즉, 다음 문제는 그 유명한 못 생긴 수이고, 오늘 문제는 이 문제로 갑시다. https://leetcode.com/problems/ugly-number/ Ugly Number - 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, 3, 5의 곱으로만 이루어진 수이냐? 를 물어봅니다... 더보기
307. Range Sum Query - Mutable 슬 난이도 좀 올려봅시다 ! https://leetcode.com/problems/range-sum-query-mutable/ Range Sum Query - Mutable - 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 본 문제는 구간합 문제입니다. 구간합이라함은 i ~ j 까지 데이터의 합을 말합니다. 이 문제에서는 update라는 메소드가 존재를 하는데 본 메소드를 통해서 값을 변경해나갑니다. 그 변경 값에 대한 구간합도 당연히 초기화가 되겠죠. 이를 염.. 더보기
20. Valid Parentheses https://leetcode.com/problems/valid-parentheses/ Valid Parentheses - 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 이번 문제는 굉장히 유명한 문제죠. 괄호의 짝을 구하는 문제입니다 ! 보통 자료구조 stack을 공부할 때 같이 나오는 문제로서, 쉽게 해결할 수 있는 문제입니다. 심심풀이 땅콩과 같은 문제랄까? stack을 만들어서 여는 괄호가 들어오면 stack에 집어넣습니다. 닫는 괄호가 나오면 어떻게 할.. 더보기
14. Longest Common Prefix 이번 문제는 가장 긴 접두사를 찾는 문제입니다. https://leetcode.com/problems/longest-common-prefix/ Longest Common Prefix - 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번 인덱스 단어를 비교 했을 때 접두사가 무조건 있을거라 생각.. 더보기
13. Roman to Integer 오랜만에 포스팅입니다 ! 최근 너무 바쁘군요 ㅠㅠ 그렇다고 제가 공부 안하는건 아니고, 포스팅을 할 시간이 없네요 ㅠ 그래도 꾸준히 정리를 해나가곤 있습니다. 시간이 있는 날 모두 포스팅을 하도록 하겠습니다 !! https://leetcode.com/problems/roman-to-integer/ Roman to Integer - 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 오늘 문제는 Roman to Integer 입니다. 제공되는 문자를 번역하여, Inte.. 더보기
581. Shortest Unsorted Continuous Subarray 배열이 하나 주어집니다. 이 배열은 정렬이 된 배열일 수도 있고, 안되어 있는 배열일 수도 있습니다. 그렇다면, 이 주어진 배열을 정렬된 배열로 바꾼다면 !? 어느 부분을 바꿔야할까요? 그렇다면 그 바꾸는 부분의 길이는 몇이 될까요 !? 를 물어보는 문제입니다. TestCase 하나를 보시죠. [2, 6, 4, 8, 10, 9, 15] 멀쩡해보이는 이 배열, 안을 들여다보면 뒤죽박죽, 엉망진창입니다. 이 배열을 멀쩡히 정렬된 배열로 만드려고 한다면 1번 ~ 5번 인덱스까지를 정렬하면 됩니다. 즉, 길이는 5가 됩니다. 그렇다면 이 문제 어떻게 풀 수 있을까요? 1. max / min 함수를 활용하자. 저희가 사용하는 언어 Python, 이 Python에는 max, min 함수가 내장되어 있습니다. 배열을.. 더보기
414. Third Maximum Number https://leetcode.com/problems/third-maximum-number/ Third Maximum Number - 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 정말 이 문제가 코딩 면접에서 간단하게 물어볼 수 있는 문제라고 생각합니다. 물론 저는 생각해내지 못했지만, 경이로운 해설을 발견했기에 들고 와봤습니다. 흑 왜 저는 이런 풀이법을 생각해내지 못할까요. 공부를 열심히 합시다. 제가 쓴 풀이법입니다. 정말 어디에 내놓기 창피한 풀이법.... 더보기
859. Buddy Strings https://leetcode.com/problems/buddy-strings/solution/ Buddy 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 본 문제는 문자열 A, B가 주어졌을 때, 한 쌍의 문자를 바꾸는 것으로 두 문자열이 같을 수 있는지를 확인하는 문제입니다. 이 전 문제 non-decreasing에서 한 번 호되게 당한 적이 있기에 이번 문제에서는 경우를 세세하게 나누어서 if 문으로 처리를 해주었습니다. class Solu.. 더보기

반응형
LIST