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
"use client"; | |
import React, { useState } from "react"; | |
import { AnimatePresence, motion } from "framer-motion"; | |
import Image from "next/image"; | |
import clsx from "clsx"; | |
type Props = { | |
onPick?: (card: string | null) => void; | |
onSelect?: (card: string) => void; | |
}; |
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
# for NVM | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm | |
[ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion | |
# place this after nvm initialization! | |
# check for .nvmrc file and run `nvm use` automatically | |
autoload -U add-zsh-hook | |
load-nvmrc() { | |
# check for .nvmrc file |
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 countHighlyProfitableMonths(stockPrices, k) { | |
// write your code here | |
let numOfProfitableMonths = 0 | |
let stockPriceLen = stockPrices.length | |
let profitableMonthsArr = [stockPrices[0]] | |
for (let i = 1; i < stockPriceLen; i += 1) { | |
const currStockPrice = stockPrices[i] | |
// checking current stock price against the profitable array | |
if (currStockPrice > profitableMonthsArr[profitableMonthsArr.length - 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
// given a string, give me the count of each particular character in the string. | |
// Hard mode: Give me the letter which is repeated the most in a row, regardless of how often the character appears in the string. | |
// “aaabbc” would return “a” | |
// “aaabbbbc” would return “b” | |
// “aaabbbbaacc” would return “b” | |
// “abababababcccababababababab” would return “c” | |
let strArr = [ | |
`aaabbc`, // a | |
`aaabbbbc`, // b |
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
const timeConversion = (s) => { | |
const seperator = `:` | |
const timeArr = s.slice(0, 8).split(seperator); | |
const hours = parseInt(timeArr[0], 10); | |
if (s.toUpperCase().indexOf(`PM`) > -1) { | |
// handle PM | |
timeArr[0] = (hours < 12) ? (hours + 12).toString() : hours.toString() | |
} else { | |
// handle AM |
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
// I liked reduce. It's weird, but it's quirky, but I don't find it easy to understand at quick glance for all devs | |
const minSum_short = (num, k) => { | |
return new Array(k) | |
.fill(undefined) // not crazy about this aspect | |
.reduce( | |
(prev) => { | |
// Sort the array high to low | |
const current = prev.sort((a, b) => b - a) | |
// Swap the maximum value with the updated one | |
current[0] = Math.ceil(current[0] / 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
package interviewProject; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
import java.util.stream.IntStream; | |
public class InterviewMain { | |
public static void main(String[] args) { | |
// Prime Number detector |
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 InterviewProject; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
import java.util.stream.IntStream; | |
public class InterviewMain { | |
public static void main(String[] args) { | |
// Prime Number detector |
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
var express = require("express") | |
var app = express() | |
var bodyParser = require("body-parser") | |
var mongoose = require("mongoose") | |
var userSchema = mongoose.Schema({ | |
name: String, | |
email: String, | |
password: String, | |
token: String, // this is for the example code, JWT would be used in a real life scenario |
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
const constructPropertyFromArgs = function (fn, args) { | |
return [].concat(fn.name, args).join('|'); | |
} | |
const memoize = function (fn) { | |
const cache = {} | |
return function(...args) { | |
const propCheck = constructPropertyFromArgs(fn, args); | |
if (!cache[propCheck]) { |
NewerOlder