Category: Algorithm

  • (KOR) N과 M(3)

    Problem – ⭐️⭐️⭐️ https://www.acmicpc.net/problem/15651 Solution Key Points Use StringBuilder to print all outputs instead of System.out.println Backtracking removes the case that we already checked

  • (KOR) N과 M(2)

    Problem – ⭐️⭐️⭐️⭐️⭐️ https://www.acmicpc.net/problem/15650 Solution Key Points Use StringBuilder to print all outputs instead of System.out.println Backtracking removes the case that we already checked

  • (KOR) N과 M(1)

    Problem – ⭐️⭐️⭐️⭐️⭐️ https://www.acmicpc.net/problem/15649 Solution Key Points Use StringBuilder to print all outputs instead of System.out.println Backtracking removes the case that we already checked Backtracking is used when we have to print all or get all cases.

  • Tree Problem Solutions

    Top-Down Solution Using the value that came up with the first node, pass the value to the children nodes. It can be considered as pre-order tree traversal. If you can use parameters and the value of the node itself to determine what should be the parameters passed to its children,…

  • BFS and DFS

    BFS and DFS

    Breadth-First Search Breadth-First search is commonly used to find the shortest path from the root node to target node. Implementation Note that we used visited hash set to skip adding duplicate nodes, but there are some cases where one does not need the visited hash. Depth-First Search Depth-First search can…

  • Tree Traversal

    Tree Traversal

    Tree is a frequently used data structure that simulates a tree structure. Each node of the tree will have a root value and a list of subtrees of child nodes. There are 3 different ways to traverse all nodes in the tree. Pre-order Traversal (NLR) Visit the root node first.…