Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 { | |
private int dfsArea(int[][] grid, int x, int y, int X, int Y) { | |
if (x < 0 || x >= X || y < 0 || y >= Y) | |
return 0; | |
if (grid[y][x] == 0 || grid[y][x] == -1) { | |
return 0; | |
} | |
grid[y][x] = -1; | |
return 1 |
This file contains hidden or 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
bool lastDigit(int a, int b, int c) { | |
int a1 = a % 10; | |
int b1 = b % 10; | |
int c1 = c % 10; | |
return a1 * b1 == c1 | |
} |
This file contains hidden or 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
bool rightTriangle(int a, int b, int c) { | |
if (a == 0 || a < 0 || b == 0 || b < 0 || c == 0 || c < 0) | |
return false; | |
if (a*a + b*b = c*c) | |
return true; | |
else if (b*b + c*c = a*a) | |
return true; | |
else if (a*a + c*c = a*a) | |
return true; |
This file contains hidden or 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
guests = ['john', 'mary', 'james', 'alex'] | |
def send_invite(guests): | |
for guest in guests: | |
print ('Welcome {}'.format(guest)) | |
#send_invite(guests) | |
guests_unavailable = ['john', 'james'] |
This file contains hidden or 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 com.pinterest.bpin.app; | |
import java.util.List; | |
import java.util.Stack; | |
public class RedblackTree { | |
enum WalkType { | |
INORDER, | |
PREORDER, | |
POSTORDER |
This file contains hidden or 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 queue; | |
import java.util.concurrent.locks.Condition; | |
import java.util.concurrent.locks.Lock; | |
import java.util.concurrent.locks.ReentrantLock; | |
public class MPMCQueue<E> { | |
private final int capacity; | |
private final Object[] data; | |
private int readIndex = 0; |
This file contains hidden or 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
/// this is a more faster version | |
class Solution { | |
int helper(const string& s, int left, int right, vector<vector<int>>& dp) { | |
if (left == right) { | |
return 1; | |
} | |
if (left > right) { | |
return 0; | |
} | |
if (dp[left][right] != -1) |
This file contains hidden or 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 { | |
int helper(const string& s, int left, int right) { | |
if (left == right) { | |
return 1; | |
} | |
if (left > right) { | |
return 0; | |
} | |
if (s[left] == s[right]) { | |
return 2 + helper(s, left+1, right-1); |
This file contains hidden or 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 { | |
bool helper(string& s1, int i, string& s2, int j, string& s3, int k, vector<vector<vector<int>>>& tb) { | |
if (i == s1.size() && j == s2.size() && k == s3.size()) { | |
return true; | |
} | |
else if (i == s1.size() && j != s2.size()) { | |
if (s2[j] == s3[k]) { | |
if (tb[i][j+1][k+1] != -1) | |
return tb[i][j+1][k+1] == 1; | |
if (helper(s1, i, s2, j+1, s3, k+1, tb)) { |
NewerOlder