类别归档:LeetCode

LeetCode OJ is a platform for preparing technical coding interviews.

RSS feed of LeetCode

[LeetCode]Constrained Subsequence Sum

题目描述: 

Given an integer array nums and an integer k, return the maximum sum of a non-empty subsequence of that array such that for every two consecutive integers in the subsequence, nums[i] and nums[j], where i < j ...

继续阅读

[LeetCode]Minimum Number of Frogs Croaking

题目描述:

LeetCode 1419. Minimum Number of Frogs Croaking

Given the string croakOfFrogs, which represents a combination of the string "croak" from different frogs, that is, multiple frogs can croak at the same time, so multiple “croak” are mixed. Return ...

继续阅读

[LeetCode]Optimize Water Distribution in a Village

题目描述:

LeetCode 1168. Optimize Water Distribution in a Village

There are n houses in a village. We want to supply water for all the houses by building wells and laying pipes.

For each house i, we can either build a ...

继续阅读

[LeetCode]Print FooBar Alternately

题目描述:

LeetCode 1115. Print FooBar Alternately

Suppose you are given the following code:

class FooBar {
  public void foo() {
    for (int i = 0; i < n; i++) {
      print("foo");
    }
  }

  public void bar() {
    for ...

继续阅读

[LeetCode]Print in Order

题目描述:

LeetCode 1114. Print in Order

Suppose we have a class:

public class Foo {
  public void first() { print("first"); }
  public void second() { print("second"); }
  public void third() { print("third"); }
}

The same instance of Foo will be passed ...

继续阅读