전체 글
-
566. Reshape the Matrix javaLeetCode_Study_Plan/Programming Skills 2022. 9. 21. 13:16
https://leetcode.com/problems/reshape-the-matrix/?envType=study-plan&id=programming-skills-i Reshape the Matrix - 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 int[][] matrixReshape(int[][] mat, int r, int c) { int[][] ans = new int[r][c]; if ((r == mat.length && c == mat[..
-
1572. Matrix Diagonal Sum javaLeetCode_Study_Plan/Programming Skills 2022. 9. 21. 00:13
https://leetcode.com/problems/matrix-diagonal-sum/?envType=study-plan&id=programming-skills-i class Solution { public int diagonalSum(int[][] mat){ int sum = 0; for(int i = 0; i < mat.length; i++){ for(int j = 0; j < mat.length; j++){ if (i==j || i+j == mat.length - 1){ sum += mat[i][j]; } } } return sum; } public static void main(String[] args){ Solution sol = new Solution(); int[][] mat = {{1,..
-
1672. Richest Customer Wealth javaLeetCode_Study_Plan/Programming Skills 2022. 9. 21. 00:03
https://leetcode.com/problems/richest-customer-wealth/?envType=study-plan&id=programming-skills-i Richest Customer Wealth - 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 int maximumWealth(int[][] accounts) { int max = -1; for(int i = 0; i < accounts.length..
-
283. Move Zeroes javaLeetCode_Study_Plan/Programming Skills 2022. 9. 20. 23:52
https://leetcode.com/problems/move-zeroes/?envType=study-plan&id=programming-skills-i class Solution { public void moveZeroes(int[] nums) { int from = -1, to = -1; for(int i = 0 ; i -1){ to = j; nums[from] = nums[to]; nums[to] = 0; from = -1; to = -1; break; } } // System.out.pr..
-
1588. Sum of All Odd Length Subarrays javaLeetCode_Study_Plan/Programming Skills 2022. 9. 20. 23:26
https://leetcode.com/problems/sum-of-all-odd-length-subarrays/?envType=study-plan&id=programming-skills-i class Solution { public int sumOddLengthSubarrays(int[] arr) { int sum = 0; for(int i = 1 ; i
-
1232. Check If It Is a Straight Line javaLeetCode_Study_Plan/Programming Skills 2022. 9. 20. 21:48
https://leetcode.com/problems/check-if-it-is-a-straight-line/?envType=study-plan&id=programming-skills-i Check If It Is a Straight Line - 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 기본부터 다시.. 자바의 자료형을 잘 모르니까 많은 실수가 있었다. 자바의 기초부터 제대로 공부해야겠다..ㅎ package com.company; import java.ut..
-
496. Next Greater Element I javaLeetCode_Study_Plan/Programming Skills 2022. 9. 20. 21:09
https://leetcode.com/problems/next-greater-element-i/?envType=study-plan&id=programming-skills-i Next Greater Element I - 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 int[] nextGreaterElement(int[] nums1, int[] nums2) { int[] ans = new int[nums1.length]; ..
-
589. N-ary Tree Preorder Traversal javaLeetCode_Study_Plan/Programming Skills 2022. 9. 20. 17:51
https://leetcode.com/problems/n-ary-tree-preorder-traversal/?envType=study-plan&id=programming-skills-i class Solution { public List preorder(Node root) { List ret = new ArrayList(); traverse(root, ret); return ret; } public void traverse(Node root, List ret){ if (root==null) return; ret.add(root.val); for (Node child: root.children){ traverse(child, ret); } } }