Swift Coding Test Course, Interval Sum Calculation 1

Introduction

In today’s lecture, we will delve deep into the problem of calculating range sums. This problem frequently appears in various algorithmic challenges, and it’s essential to know efficient solutions.
In this article, we will define the problem, explain various approaches, and detail the process of finding the optimal solution.

Problem Definition

Given an array A and two integers L and R, calculate the value of
A[L] + A[L+1] + ... + A[R].
Assume that the index of A starts from 1.

Input

  • First line: Integer N (1 ≤ N ≤ 100,000) – Size of the array
  • Second line: N integers A[1], A[2], ..., A[N] (-1,000,000 ≤ A[i] ≤ 1,000,000)
  • Third line: Integer Q (1 ≤ Q ≤ 100,000) – Number of queries
  • Next Q lines: Each query contains two integers L and R

Output

For each query, output the range sum result line by line.

Problem Approach

There are several methods to solve this problem. A straightforward approach is to compute the sum directly for each query, but
this can be inefficient in terms of time complexity. Therefore, we will consider the following approach.

1. Approach through Simple Iteration

The most basic method is to use a loop to calculate the range sum for each query directly.
The time complexity of this method is O(N), and if there are Q queries, it becomes O(N*Q).
This would require up to a billion calculations in the worst-case scenario when both N and Q are at their maximum of 100,000, which is impractical.

2. Using a Cumulative Sum Array

Thus, using a cumulative sum array to solve the problem is much more efficient. With this approach,
the range sum can be resolved in O(1) time complexity. By creating a cumulative sum array and preprocessing the data linearly,
we can obtain results in O(1) time for each query.

Definition of Cumulative Sum Array

We will define the array p as follows:
p[i] = A[1] + A[2] + ... + A[i]
This way, the range sum A[L] + A[L+1] + ... + A[R] can be easily calculated as
p[R] - p[L-1].

Implementation

Now, let’s proceed with the actual implementation. I will write the algorithm using Swift.


    import Foundation

    // Input
    let n = Int(readLine()!)!
    let a = readLine()!.split(separator: " ").map { Int($0)! }
    let q = Int(readLine()!)!

    // Initialize cumulative sum array
    var p = [0] + a
    
    // Create cumulative sum array
    for i in 1..<n+1 {="" p[i]="p[i-1]" +="" a[i-1]="" }="" process="" each="" query="" for="" _="" in="" 0..<q="" let="" lr="readLine()!.split(separator:" "="" ").map="" int($0)!="" l="lr[0]" r="lr[1]" print(p[r]="" -="" p[l-1])="" <="" code=""></n+1>
<h2>Results and Analysis</h2> <p> The above code constructs the cumulative sum array in O(N) time complexity and<br> prints the answer for each query in O(1) time.<br> In the worst-case scenario, considering the time spent on input, the overall time complexity is O(N + Q). </p> <h3>Advantages of the Optimized Approach</h3> <p> This method shows excellent performance, especially with large input data.<br> The use of cumulative sums allows for efficient handling of numerous queries.<br> Such problem-solving methods can be applied to other challenges and require a basic understanding of data structures. </p> <h2>Conclusion</h2> <p> Today, we explored an efficient problem-solving method using cumulative sum arrays through the problem of calculating range sums.<br> Many algorithmic problems practically utilize such techniques, so it is essential to grasp them.<br> In the next lecture, we will cover similar problems.<br> I hope this is helpful for your coding test preparation. </p> <p></p>
<footer class="entry-footer"> <span class="byline"><span class="author vcard"><img alt="" src="https://secure.gravatar.com/avatar/5b7f47db621d1eab02540d35048be506?s=49&amp;d=mm&amp;r=g" srcset="https://secure.gravatar.com/avatar/5b7f47db621d1eab02540d35048be506?s=98&amp;d=mm&amp;r=g 2x" class="avatar avatar-49 photo" height="49" width="49" decoding="async"><span class="screen-reader-text">Author </span> <a class="url fn n" href="https://atmokpo.com/w/en/author/root/">root</a></span></span><span class="posted-on"><span class="screen-reader-text">Posted on </span><a href="https://atmokpo.com/w/34686/" rel="bookmark"><time class="entry-date published" datetime="2024-11-01T09:30:53+00:00">2024/11/01</time><time class="updated" datetime="2024-11-01T11:26:59+00:00">2024/11/01</time></a></span><span class="cat-links"><span class="screen-reader-text">Categories </span><a href="https://atmokpo.com/w/category/swift-coding-test/" rel="category tag">Swift Coding Test</a></span> </footer><!-- .entry-footer -->
<article id="post-34684" class="post-34684 post type-post status-publish format-standard hentry category-swift-coding-test"> <header class="entry-header"> <h2 class="entry-title"><a href="https://atmokpo.com/w/34684/" rel="bookmark">Swift Coding Test Course, Interval Sum</a></h2> </header><!-- .entry-header --> <div class="entry-content"> <p></p> <h2>Problem Description</h2> <p>Given an integer array <code>nums</code> and two integers <code>start</code> and <code>end</code>, this is a problem to calculate the value of <code>nums[start] + nums[start + 1] + ... + nums[end]</code>. We will explore methods to efficiently calculate the range sum and how to solve this problem in Swift.</p> <h2>Input Example</h2> <pre><code>[1, 2, 3, 4, 5], start = 1, end = 3</code></pre> <h2>Output Example</h2> <pre><code>9</code></pre> <h2>Approach to the Problem</h2> <p>To solve this problem, we need to consider how to perform range addition efficiently. A simple way is to use a <code>for</code> loop to calculate the sum over the given index range. However, there is much room for improvement with this approach.</p> <h3>1. Sum Calculation Using Simple Loop</h3> <p>First, let’s take a look at the most basic method. This involves using a loop to calculate the sum for the given range. Below is the Swift code implementing this method.</p> <pre><code>func rangeSum(nums: [Int], start: Int, end: Int) -&gt; Int { var sum = 0 for i in start...end { sum += nums[i] } return sum }</code></pre> <h4>Usage Example</h4> <pre><code>let nums = [1, 2, 3, 4, 5] let result = rangeSum(nums: nums, start: 1, end: 3) print(result) // 9</code></pre> <h3>2. Approach Using Cumulative Sum Array</h3> <p>A simple loop can lead to performance degradation in certain cases. Particularly, if we need to calculate the range sum multiple times for a large array, executing a loop each time is inefficient. In such cases, using a cumulative sum array is an effective approach.</p> <p>By using a cumulative sum array, we can calculate the sum of a specific range of the array in constant time <code>O(1)</code>. The approach is as follows:</p> <ol> <li>Create a cumulative sum array of the same size as the input array.</li> <li>Add the cumulative sum of the previous index to each index of the cumulative sum array.</li> <li>To calculate the range sum, we can easily compute it using <code>prefixSum[end + 1] - prefixSum[start]</code>.</li> </ol> <h4>Cumulative Sum Array Implementation Code</h4> <pre><code>func rangeSumUsingPrefix(nums: [Int], start: Int, end: Int) -&gt; Int { var prefixSum = [0] // Initialize cumulative sum array prefixSum.append(0) // Initialize the first index to 0 // Generate cumulative sum array for num in nums { prefixSum.append(prefixSum.last! + num) } // Calculate range sum return prefixSum[end + 1] - prefixSum[start] }</code></pre> <h4>Usage Example</h4> <pre><code>let nums = [1, 2, 3, 4, 5] let result = rangeSumUsingPrefix(nums: nums, start: 1, end: 3) print(result) // 9</code></pre> <h2>Case Analysis</h2> <p>In this lecture, we have examined two approaches to solve the range sum problem. The method using a simple loop is intuitive and easy to understand, but can lead to performance degradation for large arrays. On the other hand, the method utilizing cumulative sum arrays is superior in terms of performance.</p> <h2>Conclusion</h2> <p>The range sum problem is a great example of utilizing algorithms and data structures. We learned that efficient approaches can lead to quicker solutions to problems. Try solving such problems using Swift and familiarize yourself with various algorithmic techniques.</p> <h3>References</h3> <ul> <li>Swift Official Documentation: <a href="https://developer.apple.com/documentation/swift">developer.apple.com</a></li> <li>Data Structures and Algorithms Book: <a href="https://www.example.com/book">example.com</a></li> </ul> <p></p> </div><!-- .entry-content --> <footer class="entry-footer"> <span class="byline"><span class="author vcard"><img alt="" src="https://secure.gravatar.com/avatar/5b7f47db621d1eab02540d35048be506?s=49&amp;d=mm&amp;r=g" srcset="https://secure.gravatar.com/avatar/5b7f47db621d1eab02540d35048be506?s=98&amp;d=mm&amp;r=g 2x" class="avatar avatar-49 photo" height="49" width="49" decoding="async"><span class="screen-reader-text">Author </span> <a class="url fn n" href="https://atmokpo.com/w/en/author/root/">root</a></span></span><span class="posted-on"><span class="screen-reader-text">Posted on </span><a href="https://atmokpo.com/w/34684/" rel="bookmark"><time class="entry-date published" datetime="2024-11-01T09:30:51+00:00">2024/11/01</time><time class="updated" datetime="2024-11-01T11:26:59+00:00">2024/11/01</time></a></span><span class="cat-links"><span class="screen-reader-text">Categories </span><a href="https://atmokpo.com/w/category/swift-coding-test/" rel="category tag">Swift Coding Test</a></span> </footer><!-- .entry-footer --> </article><!-- #post-34684 --> <article id="post-34680" class="post-34680 post type-post status-publish format-standard hentry category-swift-coding-test"> <header class="entry-header"> <h2 class="entry-title"><a href="https://atmokpo.com/w/34680/" rel="bookmark">Swift Coding Test Course, Finding the Number of Steps</a></h2> </header><!-- .entry-header --> <div class="entry-content"> <p></p> <p>Hello everyone! Today, we will tackle one of the frequently appearing problems in coding tests, the ‘<strong>Counting Stair Numbers</strong>‘ problem. In this article, we will explore the definition of the stair number problem, the solution methods, and step-by-step Swift code examples. Ultimately, we will include efficient and concise code implementations along with various test cases.</p> <h2>Problem Definition</h2> <p>A stair number (n) is a number of length n, meaning that the difference between two consecutive digits is 1. For example, 123, 234, and 321 are stair numbers. However, 122 and 3456 are not stair numbers. Your task is to calculate the count of n-digit stair numbers for a given n.</p> <h2>Examples of the Problem</h2> <p>Let’s take an example of finding stair numbers with a given number of digits (n) using the digits from 1 to 9. Here are some examples:</p> <ul> <li>n = 1: Result = 9 (1, 2, 3, 4, 5, 6, 7, 8, 9)</li> <li>n = 2: Result = 17 (10, 12, 21, 23, 32, 34, 43, 45, 54, 56, 65, 67, 76, 78, 87, 89, 90)</li> <li>n = 3: Result = 32 (101, 121, 123, 210, 212, …)</li> </ul> <h2>Approach to Solve the Problem</h2> <p>To solve this problem, we can use the Dynamic Programming technique. We solve the problem by utilizing the relationship between one-digit numbers and numbers above it, based on the properties of stair numbers.</p> <h3>Dynamic Programming Approach</h3> <p>First, we set the length of the stair number to n and establish a dp array to store the possible counts. dp[i][j] represents the count of stair numbers of length i with the last digit j. This allows us to set up a recurrence relation:</p> <pre> dp[i][j] = dp[i-1][j-1] + dp[i-1][j+1] </pre> <p>Here, j takes on values from 0 to 9. If the last digit is 0, the previous digit can only be 1, and if the last digit is 9, the previous digit can only be 8. Note that intermediate values can go both ways.</p> <h3>Basic Setup</h3> <p>Now, let’s initialize the DP table for solving the problem. Since the first digit of the stair numbers can only be from 1 to 9:</p> <pre> for j in 0...9 { dp[1][j] = 1 } </pre> <p>Next, we will set up a loop from the second digit up to n digits to fill the dp array.</p> <h2>Swift Code Implementation</h2> <p>Now, based on what we’ve explained above, let’s implement the code in Swift.</p> <pre> func countStairNumbers(n: Int) -&gt; Int { // Array to store the count of stair numbers for each digit var dp = Array(repeating: Array(repeating: 0, count: 10), count: n + 1) // For 1-digit numbers, there is 1 case for each from 1 to 9 for j in 1...9 { dp[1][j] = 1 } // Fill the DP array for i in 2...n { for j in 0...9 { if j &gt; 0 { dp[i][j] += dp[i - 1][j - 1] } if j &lt; 9 { dp[i][j] += dp[i - 1][j + 1] } } } var totalCount = 0 // Sum up all cases for n-digit numbers for j in 0...9 { totalCount += dp[n][j] } return totalCount } // Usage example let result = countStairNumbers(n: 3) print("Count of 3-digit stair numbers: \(result)") // Output: 32 </pre> <h2>Code Explanation</h2> <p>The above code returns the count of n-digit stair numbers for a given n. The function sets up the dp array and calculates each possible case by adding the possibilities for each digit. Ultimately, it returns the total count of all n-digit numbers.</p> <h2>Test Cases</h2> <p>Let's create a few test cases to verify the correct operation of the function by checking the results for each digit count:</p> <pre> print("1-digit count: \(countStairNumbers(n: 1))") // 9 print("2-digit count: \(countStairNumbers(n: 2))") // 17 print("3-digit count: \(countStairNumbers(n: 3))") // 32 print("4-digit count: \(countStairNumbers(n: 4))") // X (to be computed and verified) print("5-digit count: \(countStairNumbers(n: 5))") // Y (to be computed and verified) </pre> <h2>Conclusion</h2> <p>Today, we learned how to solve the counting stair numbers problem using Swift. We were able to devise an efficient solution to this problem through dynamic programming. I encourage you to understand and utilize this problem to tackle more algorithmic challenges!</p> <p>Then, we'll see you next time with more interesting topics. Thank you!</p> <p></p> </div><!-- .entry-content --> <footer class="entry-footer"> <span class="byline"><span class="author vcard"><img alt="" src="https://secure.gravatar.com/avatar/5b7f47db621d1eab02540d35048be506?s=49&amp;d=mm&amp;r=g" srcset="https://secure.gravatar.com/avatar/5b7f47db621d1eab02540d35048be506?s=98&amp;d=mm&amp;r=g 2x" class="avatar avatar-49 photo" height="49" width="49" decoding="async"><span class="screen-reader-text">Author </span> <a class="url fn n" href="https://atmokpo.com/w/en/author/root/">root</a></span></span><span class="posted-on"><span class="screen-reader-text">Posted on </span><a href="https://atmokpo.com/w/34680/" rel="bookmark"><time class="entry-date published" datetime="2024-11-01T09:30:48+00:00">2024/11/01</time><time class="updated" datetime="2024-11-01T11:27:00+00:00">2024/11/01</time></a></span><span class="cat-links"><span class="screen-reader-text">Categories </span><a href="https://atmokpo.com/w/category/swift-coding-test/" rel="category tag">Swift Coding Test</a></span> </footer><!-- .entry-footer --> </article><!-- #post-34680 --> <article id="post-34682" class="post-34682 post type-post status-publish format-standard hentry category-swift-coding-test"> <header class="entry-header"> <h2 class="entry-title"><a href="https://atmokpo.com/w/34682/" rel="bookmark">Swift Coding Test Course, Finding the Product of an Interval</a></h2> </header><!-- .entry-header --> <div class="entry-content"> <p></p> <p>One of the common problems encountered in programming interviews or coding tests is ‘Calculating the Product of an Interval’. This problem requires a deep understanding of data structures and algorithms through the efficient calculation of the product over a specific interval of a given array. In this chapter, we will understand this problem and explore efficient solutions.</p> <h2>Problem Definition</h2> <p>Given an integer array <code>nums</code> and multiple queries <code>queries</code>, the task is to return the product of the interval defined by each query. The product of an interval refers to the result of multiplying all the numbers within that interval.</p> <h3>Example Problem</h3> <pre>Example: Input: nums = [1, 2, 3, 4, 5] Queries: queries = [[0, 1], [1, 3], [2, 4]] Output: [2, 24, 60] Explanation: - The first query [0, 1] returns nums[0] * nums[1] = 1 * 2 = 2. - The second query [1, 3] returns nums[1] * nums[2] * nums[3] = 2 * 3 * 4 = 24. - The third query [2, 4] returns nums[2] * nums[3] * nums[4] = 3 * 4 * 5 = 60. </pre> <h2>Solution Approach</h2> <p>The problem of calculating the product of an interval can be solved using a basic double loop. However, if the number of queries is large and the array is big, a double loop is inefficient, and we should consider other methods. Particularly, if the number of queries is N and each query takes O(M) time to calculate the interval product, the worst-case time complexity is O(N * M). Therefore, we need to find a method that can solve it in O(N + Q) time.</p> <h2>Calculating Interval Products in Linear Time Complexity</h2> <p>We can solve this problem using a technique called prefix product (pre-computation). This method helps to quickly calculate the product of an interval using the starting and ending indices of each query.</p> <h3>Calculating Prefix Product</h3> <p>First, we construct a prefix product array. The prefix product array is defined with the name <code>prefixProduct</code>, where <code>prefixProduct[i]</code> represents <code>nums[0] * nums[1] * ... * nums[i]</code>. This way, the product of the interval [i, j] can be simply calculated as <code>prefixProduct[j] / prefixProduct[i-1]</code>.</p> <h3>Swift Code Implementation</h3> <pre><code> import Foundation func rangeProduct(_ nums: [Int], _ queries: [[Int]]) -&gt; [Int] { var prefixProduct = [Int](repeating: 1, count: nums.count + 1) // Create the prefix product array for i in 0..<nums.count {="" prefixproduct[i="" +="" 1]="prefixProduct[i]" *="" nums[i]="" }="" var="" result="[Int]()" for="" query="" in="" queries="" let="" left="query[0]" right="query[1]" product="prefixProduct[right" prefixproduct[left]="" result.append(product)="" return="" example="" usage="" nums="[1," 2,="" 3,="" 4,="" 5]="" 1],="" [1,="" 3],="" [2,="" 4]]="" queries)="" print(result)="" output:="" 24,="" 60]="" <="" code=""></nums.count></code></pre><code> <h2>Code Analysis</h2> <p>The code above works through the following procedures:</p> <ol> <li><strong>Creating the Prefix Product Array:</strong> It iterates through the <code>nums</code> array to calculate the cumulative product at each position. The time complexity of this process is O(N).</li> <li><strong>Processing Queries:</strong> It checks each given query one by one and calculates the interval product. The time complexity for processing each query is O(1).</li> <li>Therefore, the overall time complexity is O(N + Q).</li> </ol> <h2>Conclusion</h2> <p>Through this tutorial, we have learned how to efficiently solve the problem of calculating the product of an interval. Moving away from the basic double loop approach to utilizing prefix products is a method that can be applied beneficially in many algorithmic problems. Such problems are also used in various applications for data processing in reality, so it is important to understand and utilize this problem well.</p> <p>I wish you success in taking on more coding challenges and building your skills!</p> <p></p> </code></div><!-- .entry-content --><code> <footer class="entry-footer"> <span class="byline"><span class="author vcard"><img alt="" src="https://secure.gravatar.com/avatar/5b7f47db621d1eab02540d35048be506?s=49&amp;d=mm&amp;r=g" srcset="https://secure.gravatar.com/avatar/5b7f47db621d1eab02540d35048be506?s=98&amp;d=mm&amp;r=g 2x" class="avatar avatar-49 photo" height="49" width="49" loading="lazy" decoding="async"><span class="screen-reader-text">Author </span> <a class="url fn n" href="https://atmokpo.com/w/en/author/root/">root</a></span></span><span class="posted-on"><span class="screen-reader-text">Posted on </span><a href="https://atmokpo.com/w/34682/" rel="bookmark"><time class="entry-date published" datetime="2024-11-01T09:30:48+00:00">2024/11/01</time><time class="updated" datetime="2024-11-01T11:27:01+00:00">2024/11/01</time></a></span><span class="cat-links"><span class="screen-reader-text">Categories </span><a href="https://atmokpo.com/w/category/swift-coding-test/" rel="category tag">Swift Coding Test</a></span> </footer><!-- .entry-footer --> </code></article><!-- #post-34682 --><code> <article id="post-34678" class="post-34678 post type-post status-publish format-standard hentry category-swift-coding-test"> <header class="entry-header"> <h2 class="entry-title"><a href="https://atmokpo.com/w/34678/" rel="bookmark">Swift Coding Test Course, Pathfinding</a></h2> </header><!-- .entry-header --> <div class="entry-content"> <p></p> <div class="container"> <p>Hello, in this lecture, we will learn how to solve the pathfinding problem using the Swift language. Pathfinding is one of the common types of problems that often appear in coding tests, where the task is to find a path between two specific nodes in a given graph. In this article, we will define the problem and thoroughly discuss the algorithms and data structures needed to solve it.</p> <h2>Problem Definition</h2> <p>Let’s consider the following problem:</p> <blockquote> <p><strong>Problem:</strong> Write a function to determine whether there exists a path between two nodes A and B in a given directed graph. The graph is provided in the form of an adjacency list, with nodes and edges represented as integers.</p> </blockquote> <p><strong>Input:</strong></p> <ul> <li>Integer N: the number of nodes (1 ≤ N ≤ 1000)</li> <li>Integer M: the number of edges (1 ≤ M ≤ 10000)</li> <li>Length of the list M: each edge indicates a direction from node u to node v in the form [u, v].</li> <li>Integer A, B: the starting node A and the ending node B to check for a path.</li> </ul> <p><strong>Output:</strong></p> <ul> <li>If there exists a path from node A to node B, print “YES”; if not, print “NO”.</li> </ul> <h2>Problem Analysis</h2> <p>This problem falls under the category of ‘path search’ in graph theory and can be solved using various methods. You can explore paths using DFS (Depth-First Search) or BFS (Breadth-First Search), both of which can effectively explore graphs in the form of adjacency lists.</p> <h2>Algorithm Selection</h2> <p>In this lecture, we will use BFS to explore the graph. BFS is an algorithm that uses a queue to explore each node level by level, making it advantageous for finding the shortest path. We will check if we can reach the destination node through graph traversal.</p> <h2>Swift Code Implementation</h2> <p>Now, let’s write the actual Swift code. Below is an example of a pathfinding function that uses BFS.</p> <pre class="code"> <code> import Foundation func canReach(start: Int, end: Int, edges: [[Int]], nodeCount: Int) -&gt; String { var adjacencyList = [[Int]](repeating: [Int](), count: nodeCount + 1) for edge in edges { adjacencyList[edge[0]].append(edge[1]) } var queue = [start] var visited = [Bool](repeating: false, count: nodeCount + 1) visited[start] = true while !queue.isEmpty { let current = queue.removeFirst() if current == end { return "YES" } for neighbor in adjacencyList[current] { if !visited[neighbor] { visited[neighbor] = true queue.append(neighbor) } } } return "NO" } // Example input let nodeCount = 6 let edges = [[1, 2], [1, 3], [2, 4], [4, 5], [3, 6]] let start = 1 let end = 5 print(canReach(start: start, end: end, edges: edges, nodeCount: nodeCount)) </code> </pre> <h2>Code Explanation</h2> <p>Analyzing the above code, it consists of the following steps:</p> <ol> <li>Create a graph in the form of an adjacency list. Store connected nodes for each node.</li> <li>Initialize a queue for BFS traversal and mark the starting node as visited.</li> <li>Repeat the following process until the queue is empty: <ul> <li>Take a node from the front of the queue.</li> <li>If the taken node is the destination node, return “YES”.</li> <li>For all adjacent nodes of the current node, add unvisited nodes to the queue and mark them as visited.</li> </ul> </li> <li>If the queue is empty but the target node has not been reached, return “NO”.</li> </ol> <h2>Complexity Analysis</h2> <p>The time complexity of the BFS algorithm is O(V + E), where V is the number of nodes and E is the number of edges. Considering the maximum conditions given in this problem, it is very efficient. The memory complexity also requires O(V + E) to store the adjacency list.</p> <h2>Testing and Applications</h2> <p>The given function can be applied to various graph structures and tested accordingly. Let’s look at a few additional test cases.</p> <pre class="code"> <code> // Additional test cases let additionalEdges1 = [[1, 2], [2, 3], [3, 4], [4, 5]] let additionalEdges2 = [[1, 2], [2, 3], [3, 4], [2, 5]] print(canReach(start: 1, end: 5, edges: additionalEdges1, nodeCount: nodeCount)) // NO print(canReach(start: 1, end: 5, edges: additionalEdges2, nodeCount: nodeCount)) // YES </code> </pre> <h2>Conclusion</h2> <p>In this lecture, we learned how to solve the pathfinding problem in graphs using Swift. We effectively solved the problem using the BFS algorithm, which is very important in coding tests. When encountering similar problems in practice, you will be able to solve them based on the knowledge gained from this lecture.</p> <p>Now it’s your turn to tackle various graph problems and enhance your algorithm skills. Keep practicing!</p> </div> <p></p> </div><!-- .entry-content --> <footer class="entry-footer"> <span class="byline"><span class="author vcard"><img alt="" src="https://secure.gravatar.com/avatar/5b7f47db621d1eab02540d35048be506?s=49&amp;d=mm&amp;r=g" srcset="https://secure.gravatar.com/avatar/5b7f47db621d1eab02540d35048be506?s=98&amp;d=mm&amp;r=g 2x" class="avatar avatar-49 photo" height="49" width="49" loading="lazy" decoding="async"><span class="screen-reader-text">Author </span> <a class="url fn n" href="https://atmokpo.com/w/en/author/root/">root</a></span></span><span class="posted-on"><span class="screen-reader-text">Posted on </span><a href="https://atmokpo.com/w/34678/" rel="bookmark"><time class="entry-date published" datetime="2024-11-01T09:30:47+00:00">2024/11/01</time><time class="updated" datetime="2024-11-01T11:27:01+00:00">2024/11/01</time></a></span><span class="cat-links"><span class="screen-reader-text">Categories </span><a href="https://atmokpo.com/w/category/swift-coding-test/" rel="category tag">Swift Coding Test</a></span> </footer><!-- .entry-footer --> </article><!-- #post-34678 --> <nav class="navigation pagination" aria-label="Posts pagination"> <h2 class="screen-reader-text">Posts pagination</h2> <div class="nav-links"><a class="prev page-numbers" href="https://atmokpo.com/w/category/swift-coding-test/page/23/?lcp_pagelistcategorypostswidget-3=6">Previous page</a> <a class="page-numbers" href="https://atmokpo.com/w/category/swift-coding-test/?lcp_pagelistcategorypostswidget-3=6"><span class="meta-nav screen-reader-text">Page </span>1</a> <span class="page-numbers dots">…</span> <a class="page-numbers" href="https://atmokpo.com/w/category/swift-coding-test/page/23/?lcp_pagelistcategorypostswidget-3=6"><span class="meta-nav screen-reader-text">Page </span>23</a> <span aria-current="page" class="page-numbers current"><span class="meta-nav screen-reader-text">Page </span>24</span> <a class="page-numbers" href="https://atmokpo.com/w/category/swift-coding-test/page/25/?lcp_pagelistcategorypostswidget-3=6"><span class="meta-nav screen-reader-text">Page </span>25</a> <span class="page-numbers dots">…</span> <a class="page-numbers" href="https://atmokpo.com/w/category/swift-coding-test/page/27/?lcp_pagelistcategorypostswidget-3=6"><span class="meta-nav screen-reader-text">Page </span>27</a> <a class="next page-numbers" href="https://atmokpo.com/w/category/swift-coding-test/page/25/?lcp_pagelistcategorypostswidget-3=6">Next page</a></div> </nav> </code>
<code> </code>
<code> <aside id="secondary" class="sidebar widget-area"> <section id="block-2" class="widget widget_block widget_search"><form role="search" method="get" action="https://atmokpo.com/w/en/" class="wp-block-search__button-outside wp-block-search__text-button wp-block-search"><label class="wp-block-search__label" for="wp-block-search__input-1">Search</label><div class="wp-block-search__inside-wrapper "><input class="wp-block-search__input" id="wp-block-search__input-1" placeholder="" value="" type="search" name="s" required=""><button aria-label="Search" class="wp-block-search__button wp-element-button" type="submit">Search</button></div></form></section><section id="block-10" class="widget widget_block"><ul class="wp-block-page-list"><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/c-coding-test-tutorials/">C++ Coding Test Tutorials</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/collection-of-c-coding-test-tutorials/">Collection of C# Coding Test Tutorials</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/deep-learning-automated-trading/">Deep learning Automated trading</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/deep-learning-natural-language-processing/">Deep learning natural language processing</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/english-sentence-study/">English sentence study</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/flutter-course/">Flutter course</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/gan-deep-learning-course/">GAN deep learning course</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/java-android-app-development/">Java Android app development</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/java-coding-test/">Java Coding Test</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/javascript-coding-test/">Javascript Coding Test</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/kotlin-android-app-development/">Kotlin Android app development</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/kotlin-coding-test/">Kotlin coding test</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/python-auto-trading/">Python Auto Trading</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/python-coding-test/">Python Coding Test</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/python-study/">Python Study</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/pytorch-study/">PyTorch Study</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/react-basics-course/">React basics course</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/spring-boot-backend-development/">Spring Boot backend development</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/swift-coding-test/">Swift Coding Test</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/swift-iphone-app-development-swiftui/">Swift iPhone app development (SwiftUI)</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/swift-iphone-app-development-uikit/">Swift iPhone app development (UIKit)</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/unity-basic/">Unity Basic</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/using-hugging-face/">Using Hugging Face</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/uwp-programming/">UWP Programming</a></li><li class="wp-block-pages-list__item"><a class="wp-block-pages-list__item__link" href="https://atmokpo.com/w/wpf-programming/">WPF Programming</a></li></ul></section><section id="listcategorypostswidget-3" class="widget widget_listcategorypostswidget"><h2 class="widget-title">Category Post List</h2><ul class="lcp_catlist" id="lcp_instance_listcategorypostswidget-3"><li><a href="https://atmokpo.com/w/34816/">Swift Coding Test Course, Union Find</a></li><li><a href="https://atmokpo.com/w/34814/">Swift Coding Test Course, Topological Sorting</a></li><li><a href="https://atmokpo.com/w/34812/">Swift Coding Test Course, Finding the Desired Integer</a></li><li><a href="https://atmokpo.com/w/34810/">Swift Coding Test Course, Creating a Traveling Salesman Route</a></li><li><a href="https://atmokpo.com/w/34806/">Swift Coding Test Course, Implementing the Euler’s Phi Function</a></li><li><a href="https://atmokpo.com/w/34808/">Swift Coding Test Course, Finding Next Greater Element</a></li><li><a href="https://atmokpo.com/w/34804/">Swift Coding Test Course, Euler Pi</a></li><li><a href="https://atmokpo.com/w/34802/">Swift Coding Test Course, Finding the Sum of Consecutive Natural Numbers</a></li><li><a href="https://atmokpo.com/w/34800/">Swift Coding Test Course, Summing Consecutive Numbers</a></li><li><a href="https://atmokpo.com/w/34798/">Swift Coding Test Course, Finding the Number of Connected Components</a></li></ul><ul class="lcp_paginator"><li><a href="https://atmokpo.com/w/category/swift-coding-test/page/24/?lcp_pagelistcategorypostswidget-3=5#lcp_instance_listcategorypostswidget-3" title="5" class="lcp_prevlink">&lt;&lt;</a></li><li><a href="https://atmokpo.com/w/category/swift-coding-test/page/24/?lcp_pagelistcategorypostswidget-3=1#lcp_instance_listcategorypostswidget-3" title="1">1</a></li><li><a href="https://atmokpo.com/w/category/swift-coding-test/page/24/?lcp_pagelistcategorypostswidget-3=2#lcp_instance_listcategorypostswidget-3" title="2">2</a></li><li><a href="https://atmokpo.com/w/category/swift-coding-test/page/24/?lcp_pagelistcategorypostswidget-3=3#lcp_instance_listcategorypostswidget-3" title="3">3</a></li><li><a href="https://atmokpo.com/w/category/swift-coding-test/page/24/?lcp_pagelistcategorypostswidget-3=4#lcp_instance_listcategorypostswidget-3" title="4">4</a></li><li><a href="https://atmokpo.com/w/category/swift-coding-test/page/24/?lcp_pagelistcategorypostswidget-3=5#lcp_instance_listcategorypostswidget-3" title="5">5</a></li><li class="lcp_currentpage">6</li><li><a href="https://atmokpo.com/w/category/swift-coding-test/page/24/?lcp_pagelistcategorypostswidget-3=7#lcp_instance_listcategorypostswidget-3" title="7">7</a></li><li><a href="https://atmokpo.com/w/category/swift-coding-test/page/24/?lcp_pagelistcategorypostswidget-3=8#lcp_instance_listcategorypostswidget-3" title="8">8</a></li><li><a href="https://atmokpo.com/w/category/swift-coding-test/page/24/?lcp_pagelistcategorypostswidget-3=9#lcp_instance_listcategorypostswidget-3" title="9">9</a></li><li><a href="https://atmokpo.com/w/category/swift-coding-test/page/24/?lcp_pagelistcategorypostswidget-3=10#lcp_instance_listcategorypostswidget-3" title="10">10</a></li><li><a href="https://atmokpo.com/w/category/swift-coding-test/page/24/?lcp_pagelistcategorypostswidget-3=11#lcp_instance_listcategorypostswidget-3" title="11">11</a></li><span class="lcp_elipsis">...</span><li><a href="https://atmokpo.com/w/category/swift-coding-test/page/24/?lcp_pagelistcategorypostswidget-3=14#lcp_instance_listcategorypostswidget-3" title="14">14</a></li><li><a href="https://atmokpo.com/w/category/swift-coding-test/page/24/?lcp_pagelistcategorypostswidget-3=7#lcp_instance_listcategorypostswidget-3" title="7" class="lcp_nextlink">&gt;&gt;</a></li></ul></section><section id="block-3" class="widget widget_block"> <div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow"> <h3 class="wp-block-heading">최신 글</h3> <ul class="wp-block-latest-posts__list wp-block-latest-posts"><li><a class="wp-block-latest-posts__post-title" href="https://atmokpo.com/w/37979/">Unity 2D Game Development, Create a Platform Game Including Jumps, Obstacles, and Enemies.</a></li> <li><a class="wp-block-latest-posts__post-title" href="https://atmokpo.com/w/37977/">Unity 2D Game Development, Adding Effects Using Particle System Implementing visual effects such as explosions and flames using the particle system.</a></li> <li><a class="wp-block-latest-posts__post-title" href="https://atmokpo.com/w/37973/">Unity 2D Game Development, Touch Input and Mobile Game Development Creation of 2D games utilizing touch input on mobile devices.</a></li> <li><a class="wp-block-latest-posts__post-title" href="https://atmokpo.com/w/37975/">Unity 2D Game Development, Power-Up and Buff System Creating a power-up system that temporarily enhances the player’s abilities.</a></li> <li><a class="wp-block-latest-posts__post-title" href="https://atmokpo.com/w/37971/">Unity 2D Game Development, Quest and Mission System Creating a quest system where rewards are given for achieving specific goals.</a></li> </ul></div></div> </section> </aside><!-- .sidebar .widget-area --> </code>
<code> <footer id="colophon" class="site-footer"> <div class="site-info"> <span class="site-title"><a href="https://atmokpo.com/w/en/" rel="home">라이브스마트</a></span> <a href="https://wordpress.org/" class="imprint"> Proudly powered by WordPress </a> </div><!-- .site-info --> </footer><!-- .site-footer --> </code>
<code> </code>
<code> <link rel="stylesheet" id="lcp_paginator-css" href="https://atmokpo.com/w/wp-content/plugins/list-category-posts//lcp_paginator.css?ver=6.7.2" media="all"> <script src="https://atmokpo.com/w/wp-content/plugins/collapse-magic/js/collapse-magic.js?x=117&amp;ver=1.0" id="claps-main-js"></script> <script defer="" src="https://atmokpo.com/w/wp-content/plugins/koko-analytics/assets/dist/js/script.js?ver=1.6.4" id="koko-analytics-js"></script> <script src="https://atmokpo.com/w/wp-content/plugins/responsive-accordion-and-collapse/js/accordion-custom.js?ver=6.7.2" id="call_ac-custom-js-front-js"></script> <script src="https://atmokpo.com/w/wp-content/plugins/responsive-accordion-and-collapse/js/accordion.js?ver=6.7.2" id="call_ac-js-front-js"></script> <script src="https://stats.wp.com/e-202515.js" id="jetpack-stats-js" data-wp-strategy="defer"></script> <script id="jetpack-stats-js-after"> _stq = window._stq || []; _stq.push([ "view", JSON.parse("{\"v\":\"ext\",\"blog\":\"238449126\",\"post\":\"0\",\"tz\":\"0\",\"srv\":\"atmokpo.com\",\"j\":\"1:14.2.1\"}") ]); _stq.push([ "clickTrackerInit", "238449126", "0" ]); </script> <script> document.querySelectorAll("code").forEach(function(codeBlock) { // 내용에 '<'나 '>'가 포함된 경우에만 변환 if (codeBlock.innerHTML.includes("<") && codeBlock.innerHTML.includes(">")) { codeBlock.textContent = codeBlock.innerHTML; } }); </script></code>