leetcode 14

[java] Rotate Array

[참고문제] : 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 문제 풀이 생각의 흐름 - Circular Linked List 다. 보자마자, Circular Linked List로 구현하면 될 것이란 건 알았다. 다만, 자료구조를 만드는게 목표가 아니니 list로 처리하기로 함. 생각의 흐름 - 어디부터 끊어지는 지 보자. k는 받지만, 모듈러 연산은 해야..

Algorithm 2022.06.24

[java] Median of Two Sorted Arrays

[참고문제] : https://leetcode.com/problems/median-of-two-sorted-arrays/ Median of Two Sorted Arrays - 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 문제 풀이 생각의 흐름 - 이미 정렬되어 있다. 이미 정렬이 되어 있으니, 각각의 배열에서 계속 더 작은 수를 확인한다. 생각의 흐름 - 중앙값 까지만 확인해도 된다. 어짜피 필요한 건 중앙값이고, 중앙값까지만 확인하면 계산할 수 있다. 생각의..

Algorithm 2022.06.23

[java] Longest Substring Without Repeating Characters

[참고 문제] : 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 문제 풀이 생각의 흐름 - 저장하자. 필요한 건 가장 긴 길이가 무엇이냐? 그리고 이 문자가 나왔는가? 이 2가지를 저장할 필요가 있었다. 가장 긴 길이 여부는 max 계산을..

Algorithm 2022.06.23

[java] jump game 2

[참고 문제] : https://leetcode.com/problems/jump-game-ii/ Jump Game 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 문제 풀이 생각의 흐름 - DP Jump 하여 다음에 갈 위치와, 현재의 Score를 계산하는 방식이 필요할 것이라고 생각했다. 고로, DP로 풀이가 가능할 것이라고 판단 생각의 흐름 - 메모이제이션 무엇을 저장해야 할까가 그 다음 스텝이였다. 위에서 Score를 떠올렸으므로 nums와 같은 길..

Algorithm 2022.06.22