LeetCode_Study_Plan
-
🎵 19. Remove Nth Node From End of List javaLeetCode_Study_Plan/Algorithm 2022. 12. 21. 00:42
https://leetcode.com/problems/remove-nth-node-from-end-of-list/ Remove Nth Node From End of List - 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 새로운 ListNode를 생성해도 head 이후의 next까지만 연결해놓고 return을 하기에 의도한 값이 아님. 추가 해결 필요 /** * Definition for singly-linked list. * public class ListN..
-
876. Middle of the Linked List javaLeetCode_Study_Plan/Algorithm 2022. 12. 21. 00:06
https://leetcode.com/problems/middle-of-the-linked-list/ Middle of the Linked List - 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 /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNode(int val) { this.val = val; ..
-
🎵 557. Reverse Words in a String III javaLeetCode_Study_Plan/Algorithm 2022. 12. 20. 23:47
https://leetcode.com/problems/reverse-words-in-a-string-iii/ Reverse Words in a String III - 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 String reverseWords(String s) { String[] strs = s.split(" "); StringBuffer sb = new StringBuffer(); for(String str: s..
-
344. Reverse String javaLeetCode_Study_Plan/Algorithm 2022. 12. 20. 23:39
https://leetcode.com/problems/reverse-string/ Reverse 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 void reverseString(char[] s) { int left = 0, right = s.length-1; while (left < right) { char temp = s[right]; s[right] = s[left]; s..
-
167. Two Sum II - Input Array Is Sorted javaLeetCode_Study_Plan/Algorithm 2022. 12. 20. 23:30
https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/ Two Sum II - Input Array Is Sorted - 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[] twoSum(int[] numbers, int target) { int[] ans = new int[2]; for (int i = 0; i < numbers.length; i++) { ..
-
283. Move Zeroes javaLeetCode_Study_Plan/Algorithm 2022. 12. 20. 23:22
https://leetcode.com/problems/move-zeroes/ Move Zeroes - 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 void moveZeroes(int[] nums) { List a = new ArrayList(); for (int num:nums) { if (num != 0) { a.add(num); } } for (int i = 0; i < nums.leng..
-
🎵 189. Rotate Array javaLeetCode_Study_Plan/Algorithm 2022. 12. 20. 22:42
https://leetcode.com/problems/rotate-array/ Rotate Array - 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 void rotate(int[] nums, int k) { for (int i = 0; i < k; i++) { int lastNum = nums[nums.length-1]; int[] ans = new int[nums.length..
-
977. Squares of a Sorted Array javaLeetCode_Study_Plan/Algorithm 2022. 12. 20. 22:16
https://leetcode.com/problems/squares-of-a-sorted-array/ Squares of a Sorted Array - 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[] sortedSquares(int[] nums) { int[] ans = new int[nums.length]; for (int i = 0; i < nums.length; i++) { ans[i] = (int) Ma..