* Computer Science/Algorithm 83

1770. Maximum Score from Performing Multiplication Operations

문제: https://leetcode.com/problems/maximum-score-from-performing-multiplication-operations/ Maximum Score from Performing Multiplication Operations - 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 Input: nums = [-5,-3,-3,-2,7,1], multipliers = [-10,-5,3,4,6] Output: 102 Explanation..

670. Maximum Swap

문제: https://leetcode.com/problems/maximum-swap/ Maximum Swap - 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 특정 숫자가 주어지고, 최대 한 번의 digit간의 swap이 허용될 때 해당 swap을 사용하여 최대값을 만드는 문제다. class Solution { public: int maximumSwap(int num) { string s = to_string(num); int maxIdx = -1; int ma..

1871. Jump Game VII

문제: https://leetcode.com/problems/jump-game-vii/ Jump Game VII - 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번째 인덱스부터 시작해서 i + minJump 0이면 끝지점까지 도달할 수 있다는 뜻이다. class Solution { public: bool canReach(string s, int minJump, int maxJump) { vector dp(s.size()); dp[0] = true; int c..

1759. 암호 만들기

문제: https://www.acmicpc.net/problem/1759 1759번: 암호 만들기 첫째 줄에 두 정수 L, C가 주어진다. (3 ≤ L ≤ C ≤ 15) 다음 줄에는 C개의 문자들이 공백으로 구분되어 주어진다. 주어지는 문자들은 알파벳 소문자이며, 중복되는 것은 없다. www.acmicpc.net bruteforce 문제다. 알파벳이 소문자 하나씩만 unique하게 존재하기 때문에 따로 메모리를 대서 캐싱하지 않아도 된다. 알파벳이 unique하지 않은 경우 캐싱을 해줘야한다. 예를 들면, {'a', 'a', 'b', 'c'} 같은 경우가 있을 때 0번 인덱스 'a'를 사용하고 1번 인덱스를 사용하지 않는 경우 1, 0번 인덱스를 사용하지 않고 1번 인덱스를 사용하는 경우가 있는 경우 뒤..

351. Android Unlock Pattern

https://leetcode.com/problems/android-unlock-patterns/ Account Login - 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 unlock pattern하는 문제. 2차원 배열에서 방향을 줄때 상대적인 위치값을 주는게 익숙했는데 3x3로 고정되어있어서 방문했는지, 2칸 점프할 수 있는지 여부를 좀 더 효율적인 방법으로 확인 가능하다. 상대적인 위치값: {0, 1}, {1, 0}로 더하주면 각각 right로 1칸, b..

1171. Remove Zero Sum Consecutive Nodes from Linked List

문제: https://leetcode.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list/ Remove Zero Sum Consecutive Nodes from Linked List - 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 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * Lis..