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
/* | |
Your runtime beats 100.00 % of java submissions. | |
Your memory usage beats 96.65 % of java submissions. | |
*/ | |
class Solution { | |
public boolean containsNearbyAlmostDuplicate(int[] nums, int k, int t) { | |
k = Math.min(k , nums.length); | |
TreeSet<Long> set = new TreeSet(); | |
Long value; |
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
/* | |
Your runtime beats 100.00 % of java submissions. | |
Your memory usage beats 91.19 % of java submissions. | |
*/ | |
class Solution { | |
public int scoreOfParentheses(String S) { | |
int sum = 0 ; | |
int indexStart = 0; | |
int a = 0; |
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
/* | |
Your runtime beats 100.00 % of java submissions. | |
Your memory usage beats 99.18 % of java submissions. | |
*/ | |
class Solution { | |
public int minOperations(int n) { | |
return n*n/4; | |
} | |
} |
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
/* | |
Your runtime beats 98.60 % of java submissions. | |
Your memory usage beats 71.96 % of java submissions. | |
*/ | |
class Solution { | |
public boolean containsNearbyDuplicate(int[] nums, int k) { | |
k = Math.min(k,nums.length); | |
Set<Integer> set =new HashSet<Integer>(); | |
for (int j = 0 ; j < k ; j++){ |
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
/** | |
* Note: The returned array must be malloced, assume caller calls free(). | |
*/ | |
int* twoSum(int* nums, int numsSize, int target, int* returnSize){ | |
int* returnArray = malloc(2*sizeof(int)); | |
if (numsSize ==2){ | |
returnArray[0]=0; | |
returnArray[1]=1; | |
return returnArray; | |
} |
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
/* | |
Your runtime beats 79.51 % of java submissions. | |
Your memory usage beats 69.24 % of java submissions. | |
*/ | |
class Solution { | |
public boolean containsDuplicate(int[] nums) { | |
Set<Integer> set = new HashSet<Integer>(); | |
for(int i = 0 ; i < nums.length ; i++){ | |
if(!set.add(nums[i])){return true;} |
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
/* | |
Your runtime beats 100.00 % of java submissions. | |
*/ | |
class Solution { | |
public void moveZeroes(int[] nums) { | |
int j = 0; | |
for (int i = 0 ; i < nums.length-1 ; i++){ | |
if(nums[i]==0){ |
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
/* | |
Your runtime beats 100.00 % of java submissions. | |
Your memory usage beats 47.74 % of java submissions. | |
*/ | |
class Solution { | |
public int maximumWealth(int[][] accounts) { | |
int max = 0; | |
int sum = 0; | |
for (int i = 0 ; i < accounts.length ; i++){ | |
for (int j = 0 ; j < accounts[0].length ; j++){ |
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
/* | |
Your runtime beats 100.00 % of java submissions. | |
Your memory usage beats 91.56 % of java submissions. | |
*/ | |
class Solution { | |
public int[] runningSum(int[] nums) { | |
for(int i = 1 ; i < nums.length ; i++){ | |
nums[i]+=nums[i-1]; | |
} |
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
/* | |
Your memory usage beats 70.77 % of java submissions. | |
*/ | |
class Solution { | |
public List<Boolean> kidsWithCandies(int[] candies, int extraCandies) { | |
List<Boolean> list = new ArrayList<>(); | |
int max = 0; | |
for(int i = 0 ; i < candies.length ; i++){ | |
if(max<candies[i])max = candies[i]; | |
} |
OlderNewer