목록Algorithms (8)
Game Development

문제 링크 Example 1: Input: nums1 = [1,3], nums2 = [2] Output: 2.00000 Explanation: merged array = [1,2,3] and median is 2. Example 2: Input: nums1 = [1,2], nums2 = [3,4] Output: 2.50000 Explanation: merged array = [1,2,3,4] and median is (2 + 3) / 2 = 2.5. 풀이 두 배열을 하나의 배열로 합친 후 해당 배열에서 가장 중간 값을 찾아주면 됩니다. 여기서 배열의 크기가 짝수일 경우에는 중간의 2개 값을 더하고 절반의 값을 출력해주면 됩니다. class Solution { public: double findMedian..

문제 링크 ZigZag Conversion - 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 문제 The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And ..

문제 링크 Longest Palindromic Substring - 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 문제 Example 1: Input: s = "babad" Output: "bab" Note: "aba" is also a valid answer. Example 2: Input: s = "cbbd" Output: "bb" Example 3: Input: s = "a" Output: "a" Example 4: Input: s = "ac" Output..

문제 링크 Longest Substring Without Repeating Characters - 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 문제 Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: s = "bbbbb" Output: 1 Explanation: The answer is "b", with ..

문제 링크 Add Two Numbers - 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 문제 Example 1: Input: l1 = [2,4,3], l2 = [5,6,4] Output: [7,0,8] Explanation: 342 + 465 = 807. Example 2: Input: l1 = [0], l2 = [0] Output: [0] Example 3: Input: l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9] Output: [8,9..

문제 링크 Two 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 문제 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 use the same ..

Jump Point Search(JPS)를 이용하여 최단 거리를 찾아 봅시다. 실제로 큰 맵을 가진 게임에서 사용되는 JPS 알고리즘에 대해서 알아보도록 하겠습니다. [ 참고 ] 해당 포스팅에는 JPS 알고리즘을 C#으로 구현한것이 제공됩니다. JPS알고리즘 말고, JSP(b) 알고리즘, JPS(+) 알고리즘에 대해서도 조금이나마 내용이 나옵니다. JPS 알고리즘 이란 A* 알고리즘을 기반으로 한 알고리즘 중 하나인 JPS 알고리즘 입니다. JPS 알고리즘은 A*의 문제점인 갈 수 있는 노드들의 휴리스틱 값을 구한후 리스트에 넣어 연산하는 과정에 많은 오버헤드가 발생하여 속도가 느린 것을 보안한 알고리즘입니다. 이름 그대로 Jump Point Search 즉 내가 어디로 점프 해야할 지를 구하여 해당 노..

A*를 이용하여 길을 찾아 보자 게임에서 사용되되는 알고리즘 중 기초적인 알고리즘 중 하나인 A*를 알아보도록 하겠습니다. [ 참고 ] 이번 포스팅에서는 A*를 구현하는 방식에 대해서 알려드립니다. 전체적인 소스코드는 따로 주어지지 않습니다. 직접 스크립트를 작성해보며 실력을 기르시기 바랍니다. A* 알고리즘 이란 그래서 A*가 어떤 알고리즘 이냐면 현재의 위치에서 목적지 까지의 최단 경로를 구하는 알고리즘 입니다. A*에서는 크게 3가지로 구성 되어 있다고 보시면 됩니다. 1. 현재 노드까지 오는데 필요했던 비용 ( g Cost ) 2. 현재 노드에서 목적지 까지 가는데 필요한 비용 ( h Cost ) 3. 현재 노드에까지 온 비용과 목적지 까지 비용을 합친 비용 ( f Cost ) 위에 있는 3가지의..