Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Team_work_Evan_Jairo/Java/BestTimeToSell.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
class Solution {
public int maxProfit(int[] prices) {
if(prices == null){
return 0;
}

int n = prices.length;
int[] der = new int[n];
int[] izq = new int[n];

int precioMin = prices[0];
int profit = 0;

for(int i=1;i<n;i++){
if(precioMin>prices[i]){
precioMin = prices[i];
}

if(izq[i-1] > (prices[i]-precioMin)){
izq[i] = izq[i-1];
}else{
izq[i] = prices[i]-precioMin;
}
}


int precioMax = prices[n-1];
for(int i=n-2;i>=0;i--){
if(precioMax<prices[i]){
precioMax = prices[i];
}

if(der[i+1] > (precioMax-prices[i])){
der[i] = der[i+1];
}else{
der[i] = precioMax-prices[i];
}
}

for(int i=0;i<n;i++){
if(profit<(der[i]+izq[i])){
profit = der[i]+izq[i];
}
}

return profit;
}
}
27 changes: 27 additions & 0 deletions Team_work_Evan_Jairo/Java/Palidromo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
public class Solution {
public String shortestPalindrome(String s) {
if (s == null || s.isEmpty()) {
return "";
}

if (new StringBuilder(s).reverse().toString().equals(s)) {
return s;
}

int n = s.length();
String aux2 = "";

for (int i = 1; i < n; i++) {
String aux = s.substring(n - i);
String reversedAux = new StringBuilder(aux).reverse().toString();
aux2 = reversedAux + s;

String reversedAux2 = new StringBuilder(aux2).reverse().toString();
if (aux2.equals(reversedAux2)) {
break;
}
}

return aux2;
}
}
32 changes: 32 additions & 0 deletions Team_work_Evan_Jairo/Java/PatchingArray.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
public class PatchinArray
{
public static void main(String[] args)
{
//test case for the code
int[] array = {1, 3};
int n = 6;
patchesNeeded(array, n);
}

public static void patchesNeeded(int[] array, int n)
{
long nextMissing = 1;
int index = 0;
int patches = 0;

while (nextMissing <= n)
{
if (index < array.length && array[index] <= nextMissing)
{
nextMissing += array[index];
index++;
} else
{
patches++;
nextMissing += nextMissing;
}
}
System.out.println("Patches needed: " + patches);
}
}

27 changes: 27 additions & 0 deletions Team_work_Evan_Jairo/Python/BestTimeToSell.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class Solution(object):
def maxProfit(self, prices):
if not prices:
return 0

n = len(prices)
der = [0] * n
izq = [0] * n

precioMin = prices[0]

profit = 0

for i in range(1,n):
precioMin = min(precioMin,prices[i])
izq[i] = max(izq[i-1],prices[i]-precioMin)


precioMax = prices[n-1]
for i in range(n-2,-1,-1):
precioMax = max(precioMax,prices[i])
der[i] = max(der[i+1],precioMax-prices[i])

for i in range(1,n):
profit = max(profit, der[i]+izq[i])

return profit
17 changes: 17 additions & 0 deletions Team_work_Evan_Jairo/Python/Palindromo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Solution(object):
def shortestPalindrome(self,s):
if s == "":
return ""

if s == s[::-1]:
return s

n = len(s)
for i in range(1,n):
aux = s[n-i:n]
aux2 = aux[::-1] + s

if aux2 == aux2[::-1]:
break

return aux2
19 changes: 19 additions & 0 deletions Team_work_Evan_Jairo/Python/PatchingArray.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
def patchesNeeded(array, n):

valFaltantes = 1
i = 0
patches = 0

while valFaltantes <= n:
if i < len(array) and array[i] <= valFaltantes:
valFaltantes += array[i]
i += 1
else:
patches += 1
valFaltantes += valFaltantes

print("Patches needed: " + str(patches))

array = [1, 3]
n = 6
patchesNeeded(array, n)
7 changes: 7 additions & 0 deletions Team_work_Evan_Jairo/SQL/QuerySQL.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
With SalariosRankeados As (
Select Department.Name AS Department,
Employee.Name AS Employee,
Employee.Salary,
DENSE_RANK() Over (Partition by Department.Id order by Employee.Salary DESC) AS RankSalarios
From Employee Join Department ON Employee.departmentId = Department.Id
)Select Department,Employee,Salary From SalariosRankeados Where RankSalarios <= 3
29 changes: 29 additions & 0 deletions Team_work_Evan_Jairo/Typescript/BestTimeToSell.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function maxProfit(prices: number[]): number {
if (prices.length === 0) {
return 0;
}

const n = prices.length;
const der: number[] = new Array(n).fill(0);
const izq: number[] = new Array(n).fill(0);

let precioMin = prices[0];
let profit = 0;

for (let i = 1; i < n; i++) {
precioMin = Math.min(precioMin, prices[i]);
izq[i] = Math.max(izq[i - 1], prices[i] - precioMin);
}

let precioMax = prices[n - 1];
for (let i = n - 2; i >= 0; i--) {
precioMax = Math.max(precioMax, prices[i]);
der[i] = Math.max(der[i + 1], precioMax - prices[i]);
}

for (let i = 1; i < n; i++) {
profit = Math.max(profit, der[i] + izq[i]);
}

return profit;
};
25 changes: 25 additions & 0 deletions Team_work_Evan_Jairo/Typescript/Palindromo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
function shortestPalindrome(s: string): string {
if (s === "") {
return "";
}

const reverse = (str: string): string => str.split("").reverse().join("");

if (reverse(s) === s) {
return s;
}

const n = s.length;
let aux2 = "";

for (let i = 1; i < n; i++) {
const aux = s.slice(n - i);
aux2 = reverse(aux) + s;

if (aux2 === reverse(aux2)) {
break;
}
}

return aux2;
}
22 changes: 22 additions & 0 deletions Team_work_Evan_Jairo/Typescript/PatchingArray.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function patchesNeeded(array: number[], n: number): void {
let nextMissing: number = 1;
let index: number = 0;
let patches: number = 0;

while (nextMissing <= n) {
if (index < array.length && array[index] <= nextMissing) {
nextMissing += array[index];
index++;
} else {
patches++;
nextMissing += nextMissing;
console.log("nextMissing: " + nextMissing);
}
}
console.log("Patches needed: " + patches);
}

// Test case
const array: number[] = [1, 3];
const n: number = 6;
patchesNeeded(array, n);