본문 바로가기

Programming/Algorithm29

[leetcode] SymmetricTree https://leetcode.com/problems/symmetric-tree/ Symmetric Tree - 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 import exam.TreeNode; import java.util.ArrayDeque; import java.util.Queue; public class SymmetricTree { // recursive public static boolean isSymmetric(TreeNode root) { if(.. 2020. 11. 29.
[leetcode] SameTree https://leetcode.com/problems/same-tree/ Same Tree - 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 import exam.TreeNode; public class SameTree { public static boolean isSameTree(TreeNode p, TreeNode q) { if(p == null && q == null) return true; else if(p == null || q == null) retu.. 2020. 11. 29.
[leetcode] Minesweeper https://leetcode.com/problems/minesweeper/ Minesweeper - 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 import java.util.ArrayDeque; import java.util.Queue; public class Minesweeper { public static void main(String[] args) { char[][] chars = {{'E', 'E', 'E', 'E', 'E'}, {'E', 'E', .. 2020. 11. 29.
[leetcode] LongestIncreasingSubsequence https://leetcode.com/problems/longest-increasing-subsequence/ Longest Increasing Subsequence - 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 public class LongestIncreasingSubsequence { public static void main(String[] args) { System.out.println(lengthOfLIS(new int[] {10,9,2,5,3,7.. 2020. 11. 29.
[leetcode] GameofLife https://leetcode.com/problems/game-of-life/ Game of Life - 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 import java.util.Arrays; public class GameofLife { public static void main(String[] args) { gameOfLife(new int[][] { {0,1,0}, {0,0,1}, {1,1,1}, {0,0,0} }); } // Any live cell .. 2020. 11. 29.
[leetcode] DiameterofBinaryTree https://leetcode.com/problems/diameter-of-binary-tree/ Diameter of Binary Tree - 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 import exam.TreeNode; public class DiameterofBinaryTree { public static void main(String[] args) { TreeNode treeNode1 = new TreeNode(4); TreeNode treeNod.. 2020. 11. 29.
[leetcode] CourseSchedule https://leetcode.com/problems/course-schedule/ Course Schedule - 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 import java.util.ArrayList; import java.util.List; public class CourseSchedule { public static void main(String[] args) { System.out.println(canFinish(2,new int[][] {{0,.. 2020. 11. 29.
[leetcode] CombinationSum https://leetcode.com/problems/combination-sum/ Combination 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 import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; public class CombinationSum { public static void main(String[] .. 2020. 11. 29.
[leetcode] WordSearchII https://leetcode.com/problems/word-search-ii/ Word Search II - 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 import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Stack; //Complete public class WordSearchII { public static void main(Str.. 2020. 11. 29.