알고리즘 7

[programmers lv3.python] 베스트 앨범 풀이

https://school.programmers.co.kr/learn/courses/30/lessons/42579 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제 입출력 예 꾸준히 하고 있는 알고리즘 스터디에서 lv 2 까지의 문제들은 풀이를 보지 않아도 혼자서 얼추 풀 수 있었던 문제들이 대부분이었다. 모르겠는 문제의 풀이를 찾아봤을 때 이해가 바로바로 되기도 했었고 🥲 이 문제를 읽고 이해한 후, 어느 정도 해시를 써서 풀어야 겠다는 생각은 바로 했지만Dictionary 2개를 사용하는 문제였기 때문에 헷갈려서 문제 풀이를 많이 해맸다. 결국 풀이..

[boj 1244.python] '스위치 켜고 끄기' 풀이

https://www.acmicpc.net/problem/1244 1244번: 스위치 켜고 끄기 첫째 줄에는 스위치 개수가 주어진다. 스위치 개수는 100 이하인 양의 정수이다. 둘째 줄에는 각 스위치의 상태가 주어진다. 켜져 있으면 1, 꺼져있으면 0이라고 표시하고 사이에 빈칸이 하나씩 www.acmicpc.net 문제 이러한 규칙에 따라 학생들이 스위치를 조작하고 난 후의 스위치 상태를 구해야 한다. (자세한 입/출력 설명과 예제는 포스팅 상단의 문제를 참고해주길 바란다) 문제 이해 알고리즘 문제 푼 지 2주차가 되어 가니 슬슬 어느 지점에서 어떻게 생각해야 편할지 길이 보이는 것 같기도 하다. 남자와 여자의 행동 양식이 달라서, 남자 여자를 따로 생각하고, 와중에 남자/ 여자가 똑같이 해야하는 부분..

Algorithm/BaekJoon 2024.01.15

[boj 1966.python] 프린터 큐 풀이

https://www.acmicpc.net/problem/1966 1966번: 프린터 큐 여러분도 알다시피 여러분의 프린터 기기는 여러분이 인쇄하고자 하는 문서를 인쇄 명령을 받은 ‘순서대로’, 즉 먼저 요청된 것을 먼저 인쇄한다. 여러 개의 문서가 쌓인다면 Queue 자료구조에 www.acmicpc.net 문제 문제 이해 1. 예시를 읽고 아, 중요도의 순서 숫자가 큰 순서대로 중요하다는 거구나 생각했다. 현재 문서는 0번째이고, 문서의 중요도를 체크하기 위해서는 내장함수 max()를 사용하면 되겠다고 생각했다. 2. 중요한 것은, 중요도가 높은 문서가 입력되면 앞서 대기하던 문서는 뒤로 밀린다는 점이다. 그렇다면 큐를 이용해 문서의 순서를 관리하면서 문서의 중요도에 따라 출력 순서를 변경하는 식으로 ..

Algorithm/BaekJoon 2024.01.04

[leetcode 225.python] 큐를 이용한 스택 구현 (Implement Stack using Queues) 풀이

https://leetcode.com/problems/implement-stack-using-queues/ Implement Stack using Queues - LeetCode Can you solve this real interview question? Implement Stack using Queues - Implement a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (push, top, pop, and empty). Implement the leetcode.com 문제 Implement a last-in-first..

Algorithm/LeetCode 2024.01.04

[leetcode 561.python] 배열 파티션 1(Array-partition 1) 풀이

https://leetcode.com/problems/array-partition/ Array Partition - LeetCode Can you solve this real interview question? Array Partition - Given an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), ..., (an, bn) such that the sum of min(ai, bi) for all i is maximized. Return the maximized sum. leetcode.com 문제 Given an integer array nums of 2n integers, group t..

Algorithm/LeetCode 2024.01.03

[leetcode 49.python] 그룹 애너그램 (Group Anagrams) 풀이

https://leetcode.com/problems/group-anagrams/ Group Anagrams - LeetCode Can you solve this real interview question? Group Anagrams - Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase leetcode.com 문제 Given an array of strings strs, group the anagrams to..

Algorithm/LeetCode 2024.01.03