Compare commits

..

No commits in common. "dd88ef2c573d519d3c988fc86d31533bdcf5a139" and "628d674712d68a518ac993eab55c041ae3c73c8a" have entirely different histories.

6 changed files with 2 additions and 92 deletions

View File

@ -4,8 +4,6 @@
ARG VARIANT="buster" ARG VARIANT="buster"
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT} FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}
RUN sudo apt install gnupg2 -y
# ** [Optional] Uncomment this section to install additional packages. ** # ** [Optional] Uncomment this section to install additional packages. **
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here> # && apt-get -y install --no-install-recommends <your-package-list-here>

View File

@ -14,8 +14,7 @@
// Add the IDs of extensions you want installed when the container is created. // Add the IDs of extensions you want installed when the container is created.
"extensions": [ "extensions": [
"rust-lang.rust-analyzer", "rust-lang.rust-analyzer"
"LeetCode.vscode-leetcode"
], ],
// Use 'forwardPorts' to make a list of ports inside the container available locally. // Use 'forwardPorts' to make a list of ports inside the container available locally.

4
.gitignore vendored
View File

@ -1,3 +1 @@
/target /target
Cargo.lock
Cargo.toml

View File

@ -1,8 +0,0 @@
{
"leetcode.filePath": {
"default": {
"folder": "${kebab-case-name}",
"filename": "sol.${ext}"
}
}
}

View File

@ -1,33 +0,0 @@
/*
* @lc app=leetcode id=16 lang=rust
*
* [16] 3Sum Closest
*/
struct Solution {}
// @lc code=start
use std::cmp::Ordering;
impl Solution {
pub fn three_sum_closest(mut nums: Vec<i32>, target: i32) -> i32 {
nums.sort_unstable();
let mut result = nums[0] + nums[1] + nums[2];
for (i, &n) in nums.iter().enumerate() {
let (mut l, mut r) = (i + 1, nums.len() - 1);
while l < r {
let sum = n + nums[l] + nums[r];
if (target - sum).abs() < (target - result).abs() {
result = sum;
}
match sum.cmp(&target) {
Ordering::Equal => return sum,
Ordering::Less => l += 1,
Ordering::Greater => r -= 1
}
}
}
result
}
}
// @lc code=end

View File

@ -1,44 +0,0 @@
/*
* @lc app=leetcode id=1448 lang=golang
*
* [1448] Count Good Nodes in Binary Tree
*/
package main
// @lc code=start
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
import "math"
func goodNodes(root *TreeNode) int {
return subGoodNodes(root, math.MinInt)
}
func subGoodNodes(root *TreeNode, previousMax int) int {
if root == nil {
return 0
}
sum := 0
max := previousMax
if root.Val >= previousMax {
sum = 1
max = root.Val
}
sum += subGoodNodes(root.Left, max)
sum += subGoodNodes(root.Right, max)
return sum
}
// @lc code=end
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}