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
/* | |
** ---------------------------------------------------------------------------- | |
** script to create the employee table | |
** --------------------------------------------------------------------------*/ | |
CREATE TABLE employee ( | |
fName VARCHAR2(20)NOT NULL, | |
mInit CHAR(1), | |
lName VARCHAR2(20) NOT NULL, |
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
#!/bin/bash | |
APP_FOLDER_LOCATION=/Applications | |
IFS="" | |
## Install applications via brew cask | |
brew_install() { | |
execute="$(brew cask install $1 2>&1)" | |
case $execute in | |
*Warning*|*Error*) echo "Warning while installing $1: $execute" ;; | |
*successfully*) echo "$execute \n Installed $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
import location | |
import os | |
#Given a string S, containing special characters and all the alphabets, reverse the string without affecting the positions of the special characters. | |
def flipString(theString): | |
holdThese = "" | |
listChars = list(theString) |
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
import location | |
import os | |
# function which return reverse of a string | |
def reverse(s): | |
return s[::-1] | |
def isPalindrome(theString): | |
flip = reverse(theString) |
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
import os | |
from itertools import combinations | |
#Given an array of distinct integers and a sum value. Find count of triplets with sum smaller than given sum value. | |
""" | |
Input : arr[] = {-2, 0, 1, 3} | |
sum = 2. | |
Output : 2 | |
Explanation : Below are triplets with sum less than 2 |
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
# Let's bubblesort | |
def swap(a, b): | |
return b, a | |
def bubblesort(numbers): | |
length = len(numbers) | |
swapped = 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
from itertools import combinations | |
# Given an array of integers, write a function that returns true if there is a triplet (a, b, c) that satisfies a2 + b2 = c2. | |
""" | |
Input: arr[] = {3, 1, 4, 6, 5} | |
Output: True | |
There is a Pythagorean triplet (3, 4, 5). | |
""" |
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
function Animal(animal, noise) { | |
this.noise = noise; | |
this.animal = animal; | |
} | |
Animal.prototype.makeNoise = function() { | |
console.log('I\'m a ' + this.animal + ' - ' + this.noise) | |
} |
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
# Given an array of integers and a number x, find the smallest subarray with sum greater than the given value. | |
""" | |
arr[] = {1, 4, 45, 6, 0, 19} | |
x = 51 | |
Output: 3 | |
Minimum length subarray is {4, 45, 6} | |
""" | |
save = None |
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
# The cost of a stock on each day is given in an array, find the max profit that you can make by buying and selling in those days. For example, if the given array is {100, 180, 260, 310, 40, 535, 695}, the maximum profit can earned by buying on day 0, selling on day 3. Again buy on day 4 and sell on day 6. If the given array of prices is sorted in decreasing order, then profit cannot be earned at all. | |
def sell(lowidx, highidx): | |
print("time to sell -------") | |
print("buy:", lowidx) | |
print("sell:", highidx) | |
def stock(arr): | |
low = None | |
lowidx = None |
OlderNewer