코딩 인터뷰(leetcode) Flashcards

1
Q

leetcode 53. Maximum Subarray

Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.

https://leetcode.com/problems/maximum-subarray/

A
class Solution:
    def maxSubArray(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
    max_current = nums[0]
    ret = nums[0]

    for i in range(1, len(nums)):
        max_current = max(nums[i], max_current+nums[i])

        ret = max(max_current, ret)

    return ret
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

leetcode 189. rotate array (네 가지 방법으로 풀 수 있음)

Given an array, rotate the array to the right by k steps, where k is non-negative.

Input: [1,2,3,4,5,6,7] and k = 3
Output: [5,6,7,1,2,3,4]
Explanation:
rotate 1 steps to the right: [7,1,2,3,4,5,6]
rotate 2 steps to the right: [6,7,1,2,3,4,5]
rotate 3 steps to the right: [5,6,7,1,2,3,4]

Input: [-1,-100,3,99] and k = 2
Output: [3,99,-1,-100]
Explanation:
rotate 1 steps to the right: [99,-1,-100,3]
rotate 2 steps to the right: [3,99,-1,-100]

https://leetcode.com/problems/rotate-array/

A

https://leetcode.com/problems/rotate-array/solution/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

백준 11055 : 가장 큰 증가 부분 수열

https://www.acmicpc.net/problem/11055

A

https://www.acmicpc.net/source/9342428

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

백준 2206: 벽 부수고 이동하기

https://www.acmicpc.net/problem/2206

A

https://www.acmicpc.net/source/11319167

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

알고스팟(종만북) PI

https://algospot.com/judge/problem/read/PI

A

https://algospot.com/judge/submission/detail/597769

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

백준 9466 텀 프로젝트

https://www.acmicpc.net/problem/9466

A

http://blog.naver.com/gunwooyeon/220942236105

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

백준 16235 나무재테크

https://www.acmicpc.net/problem/16235

A

https://www.acmicpc.net/source/11430863

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

leetcode 238. Product of array except self

https://leetcode.com/problems/product-of-array-except-self/

A

https://leetcode.com/problems/product-of-array-except-self/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly