leetcode

command module
v0.0.0-...-7d01fd4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 5 Imported by: 0

README

LeetCode Solutions in Go

This repository contains my solutions to various LeetCode problems written in Go. Each solution is contained in its own file named after the problem title in kebab case.

Structure of the Repository

The repository is organized as follows:

leetcode.git
    add-binary.go
    binary-tree-inorder-traversal.go
    maximum-depth-of-binary-tree.go
    ...

Each file in the repository represents a different LeetCode problem. The file name is based on the URL of the problem, converted to kebab case and with a .go extension. Within each file, you'll find the solution code and any necessary comments to explain the thought process behind the solution.

How to Use the Repository

If you're also studying for LeetCode, you can use this repository as a reference for your own solutions. To use the code in this repository, simply clone the repository to your local machine:

git clone https://github.com/oarriet/leetcode.git

Once you have the repository on your local machine, you can run each solution using the Go compiler. To do this, navigate to the file, uncomment main func and run the following command:

go run .

Contributing

If you have a solution to a LeetCode problem in Go that you'd like to contribute, please feel free to submit a pull request. However, please make sure that your solution meets the following criteria:

  • The solution is written in Go.
  • The file name is based on the URL of the problem, converted to kebab case and with a .go extension.
  • The solution includes any necessary comments to explain the thought process behind the solution.

License

This repository is licensed under the MIT license. See the LICENSE file for more details.

Documentation

Overview

739. Daily Temperatures Medium Topics Companies Hint Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature. If there is no future day for which this is possible, keep answer[i] == 0 instead.

Example 1:

Input: temperatures = [73,74,75,71,69,72,76,73] Output: [1,1,4,2,1,1,0,0] Example 2:

Input: temperatures = [30,40,50,60] Output: [1,1,1,0] Example 3:

Input: temperatures = [30,60,90] Output: [1,1,0]

Constraints:

1 <= temperatures.length <= 105 30 <= temperatures[i] <= 100

907. Sum of Subarray Minimums Medium Topics Companies Given an array of integers arr, find the sum of min(b), where b ranges over every (contiguous) subarray of arr. Since the answer may be large, return the answer modulo 109 + 7.

Example 1:

Input: arr = [3,1,2,4] Output: 17 Explanation: Subarrays are [3], [1], [2], [4], [3,1], [1,2], [2,4], [3,1,2], [1,2,4], [3,1,2,4]. Minimums are 3, 1, 2, 4, 1, 1, 2, 1, 1, 1. Sum is 17. Example 2:

Input: arr = [11,81,94,43,3] Output: 444

Constraints:

1 <= arr.length <= 3 * 104 1 <= arr[i] <= 3 * 104

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL