LeetCode_Study_Plan/Algorithm
-
994. Rotting Oranges javaLeetCode_Study_Plan/Algorithm 2022. 12. 30. 00:23
https://leetcode.com/problems/rotting-oranges/description/?envType=study-plan&id=algorithm-i Rotting Oranges - LeetCode Rotting Oranges - You are given an m x n grid where each cell can have one of three values: * 0 representing an empty cell, * 1 representing a fresh orange, or * 2 representing a rotten orange. Every minute, any fresh orange that is 4-directionally adjacen leetcode.com class So..
-
🎵542. 01 Matrix javaLeetCode_Study_Plan/Algorithm 2022. 12. 27. 23:44
https://leetcode.com/problems/01-matrix/description/ 01 Matrix - LeetCode 01 Matrix - Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell. The distance between two adjacent cells is 1. Example 1: [https://assets.leetcode.com/uploads/2021/04/24/01-1-grid.jpg] Input: mat = [[0,0,0],[0,1,0],[0,0, leetcode.com 나의 경우 dfs로만 접근했었는데, 4가지 방향에 대해 우선적으로 칼큘레이션이 되었다가 그 다음 방향으..
-
116. Populating Next Right Pointers in Each NodeLeetCode_Study_Plan/Algorithm 2022. 12. 26. 14:22
https://leetcode.com/problems/populating-next-right-pointers-in-each-node/description/ Populating Next Right Pointers in Each Node - LeetCode Populating Next Right Pointers in Each Node - You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition: struct Node { int val; Node *left; Node *right; Node ..
-
🎵 617. Merge Two Binary Trees javaLeetCode_Study_Plan/Algorithm 2022. 12. 26. 13:00
https://leetcode.com/problems/merge-two-binary-trees/ Merge Two Binary Trees - LeetCode Merge Two Binary Trees - You are given two binary trees root1 and root2. Imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge the two trees into a new binary tree. leetcode.com public class Solution { public TreeNode m..
-
695. Max Area of Island javaLeetCode_Study_Plan/Algorithm 2022. 12. 22. 21:39
https://leetcode.com/problems/max-area-of-island/ Max Area of Island - 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 class Solution { int m; int n; boolean[][] visited; int[][] grid; int cnt = 0; public int maxAreaOfIsland(int[][] grid) { this.m = grid.length; this.n = grid[0].le..
-
733. Flood Fill javaLeetCode_Study_Plan/Algorithm 2022. 12. 22. 14:46
https://leetcode.com/problems/flood-fill/description/ Flood Fill - 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 class Solution { int[][] image; int m; int n; int newColor; int oldColor; boolean [][] visited; public int[][] floodFill(int[][] image, int sr, int sc, int color) { th..
-
3. Longest Substring Without Repeating Characters javaLeetCode_Study_Plan/Algorithm 2022. 12. 21. 11:24
https://leetcode.com/problems/longest-substring-without-repeating-characters/ 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 Queue를 이용한 풀이 class Solution { public static int lengthOfLongestSubstring(String s) { Queue q = new LinkedL..
-
567. Permutation in String javaLeetCode_Study_Plan/Algorithm 2022. 12. 21. 11:08
https://leetcode.com/problems/permutation-in-string/ Permutation in String - 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 class Solution { public boolean checkInclusion(String s1, String s2) { s1 = sort(s1); for (int i = 0; i < s2.length()-s1.length()+1; i++) { if (s1.equals(sor..