2020-01-02から1日間の記事一覧

LeetCode - Best Time to Buy and Sell Stock - Day2 (1/2/2020)

Best Time to Buy and Sell Stock Question Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock)…

LeetCode - House Robber - Day2 (1/2/2020)

House Robber Question You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security s…

LeetCode - Maximum Subarray - Day2 (1/2/2020)

Maximum Subarray Question Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 Explanation: [4,-1,2,1] h…

LeetCode - Find k Pairs with Smallest Sums - Day2 (1/2/2020)

Find k Pairs with Smallest Sums Question You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define a pair (u,v) which consists of one element from the first array and one element from the second ar…

LeetCode - Subarray Sum Equals K - Day2 (1/2/2020)

Subarray Sum Equals K Question Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals k. Example 1: Input:nums = [1,1,1], k = 2 Output: 2 Note: The length of the array is in …

LeetCode - Preface - Day2

Let's get started I read Shiroyama-san's blog post today and figured out it describes exactly what I think about the programming recently. Since I used to major in business and recently switched my major to computer science, I always feel …