This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int minMoves(const vector& nums) { | |
int base = *min_element(nums.cbegin(), nums.cend()); | |
return accumulate(nums.cbegin(), nums.cend(), 0) - base * nums.size(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int minMoves(vector<int>& nums) { | |
int base = numeric_limits<int>::max(); | |
int sum = 0; | |
for (int i = 0; i < nums.size(); ++i) { | |
sum += nums[i]; | |
base = min(base, nums[i]); | |
} | |
return sum - base * nums.size(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
movdqa xmm1, xmm0 | |
psrldq xmm1, 8 | |
paddd xmm0, xmm1 | |
movdqa xmm1, xmm0 | |
psrldq xmm1, 4 | |
paddd xmm0, xmm1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/main/java/com/google/devtools/build/lib/BUILD b/src/main/java/com/google/devtools/build/lib/BUILD | |
index d4e18ecf8..0beac7230 100644 | |
--- a/src/main/java/com/google/devtools/build/lib/BUILD | |
+++ b/src/main/java/com/google/devtools/build/lib/BUILD | |
@@ -434,14 +434,34 @@ java_library( | |
# | |
# IMPORTANT: NOT A PUBLIC INTERFACE. TARGETS SHOULDN'T DEPEND ON THIS. | |
# | |
-java_library( | |
+java_binary( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.sample; | |
import org.openjdk.jmh.annotations.Benchmark; | |
import org.openjdk.jmh.annotations.Scope; | |
import org.openjdk.jmh.annotations.State; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/rules/attributes/printer.bzl b/rules/attributes/printer.bzl | |
index 1a7abf1..facd739 100644 | |
--- a/rules/attributes/printer.bzl | |
+++ b/rules/attributes/printer.bzl | |
@@ -18,8 +18,8 @@ def _impl(ctx): | |
printer = rule( | |
implementation = _impl, | |
attrs = { | |
+ "deps": attr.label_list(allow_files = True), | |
# Do not declare "name": It is added automatically. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
impl Solution { | |
pub fn is_valid(s: String) -> bool { | |
let mut stack = Vec::new(); | |
let match_of = |c: char| -> char { | |
match c { | |
')' => '(', | |
'}' => '{', | |
']' => '[', | |
_ => panic!("Invalid closing bracket"), | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Definition for singly-linked list. | |
* struct ListNode { | |
* int val; | |
* ListNode *next; | |
* ListNode(int x) : val(x), next(NULL) {} | |
* }; | |
*/ | |
class Solution { | |
private: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
int maxWidthRamp(vector<int>& A) { | |
map<int, int> largest; | |
largest[A.back()] = A.size()-1; | |
int max_width = 0; | |
for (int i = A.size()-2; i >= 0; --i) { | |
auto found = largest.lower_bound(A[i]); | |
if (found != largest.cend()) { | |
max_width = max(max_width, found->second - i); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
impl Solution { | |
pub fn max_width_ramp(a: Vec<i32>) -> i32 { | |
let mut largest: Vec<usize> = vec![(a.len()-1) as usize]; | |
for (i, val) in a.iter().enumerate().rev().skip(1) { | |
if *val > a[*largest.last().unwrap()] { | |
largest.push(i); | |
} | |
} | |
let mut max_width = 0; | |
for (i, val) in a.iter().enumerate() { |
OlderNewer