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
require 'set' | |
# @param {Character[][]} grid | |
# @return {Integer} | |
def num_islands(grid) | |
puts grid.inspect | |
final_count = 0 | |
grid.length.times do |i| | |
grid.length.times do |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
def repair_whitespace(str) | |
buff = [] | |
final_words = [] | |
str.each_char do |char| | |
buff << char | |
if valid_word?(buff.join) | |
final_words << buff.join |
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
# If you come from bash you might have to change your $PATH. | |
# export PATH=$HOME/bin:/usr/local/bin:$PATH | |
# Path to your oh-my-zsh installation. | |
export ZSH=/home/kashyap/.oh-my-zsh | |
# Set name of the theme to load. Optionally, if you set this to "random" | |
# it'll load a random theme each time that oh-my-zsh is loaded. | |
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes | |
ZSH_THEME="fino" |
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
class AppSchema < Dry::Validation::Schema::Form | |
configure do |config| | |
config.type_specs = true | |
def self.messages | |
super.merge( | |
en: { errors: { | |
discount_pricing: 'are not valid.', | |
base_package_price: 'You need to have a package_price with quantity 1.', | |
package_names: 'should be unique.' | |
} } |
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
class Profit | |
attr_accessor :bp, :sp, :bp_index, :sp_index | |
def initialize(bp_index=-1, bp=0, sp_index=-1, sp=0) | |
@bp_index = bp_index || -1 | |
@bp = bp || 0 | |
@sp_index = sp_index || -1 | |
@sp = sp || 0 | |
end |
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
{"lastUpload":"2018-08-14T15:18:49.176Z","extensionVersion":"v3.0.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
const prices = [10, 7, 5, 12, 1, 89]; | |
const initialState = { | |
maxProfit: 0, | |
bestBuyPrice: prices[0], | |
}; | |
const bestProfit$ = Rx | |
.Observable | |
.from(prices) |
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
def is_prime(num) | |
i = 2 | |
while(i <= Math.sqrt(num)) | |
return false if num % i === 0 | |
i = i + 1 | |
end | |
true | |
end | |
def print_table(num) |
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
{ | |
"name": "flare", | |
"children": [ | |
{ | |
"name": "analytics", | |
"children": [ | |
{ | |
"name": "cluster", | |
"children": [ | |
{"name": "AgglomerativeCluster", "value": 3938}, |
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 ELEMENTS = 1000000; | |
const add10 = (a: number) => a + 10; | |
const isEven = (a: number) => a % 2 === 0; | |
const getInitial = (): number[] => []; | |
const combine = (acc: number[], elem: number) => (acc.push(elem), acc); | |
const compose = (...fns: Function[]) => (x: number) => fns.reduceRight<number>((acc, fn) => fn(acc), x); | |
const ip = Array.from(Array(ELEMENTS), (_, i) => i); |
OlderNewer