Data Structure & Algorithms/Arrays and Strings9 [Array and String] Prefix sum 개념 릿코드로 이번 챕터를 정주행중인데 Rrefix sum 알고리즘에 대한것은 이 블로그에서 잘 정리한듯. 핵심이 팍온다. => sum을 어레이 형태로 저장해놔서 필요에 따라 바로 바로 쓸수있도록. https://www.crocus.co.kr/843 구간 합(Prefix Sum) 알고리즘 목차 1. 구간 합(Prefix Sum)이란? 2. 구간 합(Prefix Sum)이 어디에 쓰일까? 3. Prefix Sum Algorithm 4. Prefix Sum이 쓰이는 문제들 1. 구간 합(Prefix Sum)이란? 공부를 하다보면 부분 합, 구간 합의 개념이 헷갈릴 때 www.crocus.co.kr 릿코드에서 제시한 예제 문제 (어려운데..?) https://leetcode.com/problems/number-of.. 2023. 3. 9. [Array]643. Maximum Average Subarray I https://leetcode.com/problems/maximum-average-subarray-i/description/ Maximum Average Subarray I - LeetCode Can you solve this real interview question? Maximum Average Subarray I - You are given an integer array nums consisting of n elements, and an integer k. Find a contiguous subarray whose length is equal to k that has the maximum average value and return thi leetcode.com Code template: 3. sl.. 2023. 3. 7. [Arrrays and String] 713. Subarray Product Less Than K (투포인트와 슬라이딩 윈도우 개념 헷갈림) https://leetcode.com/problems/subarray-product-less-than-k/ Subarray Product Less Than K - LeetCode Can you solve this real interview question? Subarray Product Less Than K - Given an array of integers nums and an integer k, return the number of contiguous subarrays where the product of all the elements in the subarray is strictly less than k. Example leetcode.com 코드 템플릿 : 3. Sliding window( can.. 2023. 3. 3. [arrays and strings] 997.Squares of a Sorted Array https://leetcode.com/problems/squares-of-a-sorted-array/description/ Squares of a Sorted Array - LeetCode Can you solve this real interview question? Squares of a Sorted Array - Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order. Example 1: Input: nums = [-4,-1,0,3,10] Out leetcode.com 코드 템플릿: 1. Two pointers: .. 2023. 3. 1. [Arrays and Strings] 1.Two sum - LeetCode https://leetcode.com/problems/two-sum/description/ Two Sum - LeetCode Can you solve this real interview question? Two Sum - Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not leetcode.com 코드 템플릿 : 1. Two pointers: one input, opposite ends Time com.. 2023. 2. 28. [Arrays & String] 2회독 큰그림 잡기 - 자주쓰이는 템플릿정리 후우! Leetcode data structure and algorithms 전체 챕터를 속속히는 공부하지는 않았지만 정신줄잡고 한바퀴 돌기 성공!! 이제 어느정도 큰그림이 보이기 시작한다. 결국 이 공부의 목적도 테스트에 있기에 테스트에 맞는 공부를 하면 된다. 잘 나오는 대표 공식이 몇가지가 있으니 릿코드의 code template 의 도움을 받아 정리하고 숙달하는 과정을 가져야지. 이정도 템플릿을 술술 풀어낼 수 있는 기본이 있고 문제를 보며 문제 해결과정을 습득하면 코딩 테스트 준비 끝! 5가지 템플릿 1. Two pointers: one input, opposite ends -> 두가지 포인터를 사용하는 전략이 대표적이며 처음과 끝에 포인터를 달고 계산 int fn(vector& arr) { i.. 2023. 2. 28. [Arrays] Container With Most Water 문제 You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]). Find two lines that together with the x-axis form a container, such that the container contains the most water. Return the maximum amount of water a container can store. Notice that you may not slant the container. Example 1: Input: hei.. 2022. 10. 11. [DSA] Array and String -Reverse String 제대로 코딩 공부좀 시작할려고 leetcode 결제를 감행하였다. 돈이 들어갔으니 열심히 해야한다. 막 방대한 자료를 다루지는않고 좀 더 기본적인걸 주로 다루는걸 GeeksforGeeks와 비교하여 더 최신 트랜드를 따라가는것같아 결정하였다. 오... 코딩 테스트가 이렇게 진행되는구나. Topic : Two pointers : 가장 기본적인 배치문제로 Array를 두 포인터로 위치를 옮겨가며 푸는방법이다. 문제로 스트링을 역순하는문제가 나왔고 어찌저찌풀었는데 오... 내 프로그램이 전체 서밋한 프로그램중에 어느 위치에 차지하고있는지 가르쳐주기까지! 그 이후에 답지는 정말 친절하게 효율적인 코드를 알려준다! 내가 막무가내로 풀었던 제출답 (아니 굳이 소수 짝수 안나눠도 됬구나..) class Solutio.. 2022. 10. 6. 이전 1 2 다음