Skip to content

Instantly share code, notes, and snippets.

class Solution {
fun twoSum(nums: IntArray, target: Int): IntArray {
val numberToIndexesMap = createNumberToIndexesMap(nums, target)
// Iterate through each entry
for (currEntry in numberToIndexesMap.entries) {
// Subtract it from the target
val nextValues = numberToIndexesMap[target - currEntry.key]
if (nextValues == null || nextValues.isEmpty()) {
continue
@RaviH
RaviH / .babelrc
Last active November 18, 2020 16:26
Vue, Quasar, Cypress Code Coverage via Istanbul
{
"plugins": ["@babel/plugin-syntax-dynamic-import"],
"env": {
"test": {
"plugins": ["dynamic-import-node"],
"presets": [
[
"@babel/preset-env",
{
"modules": "commonjs",
Reference Handler id=2 state=WAITING
- waiting on <0x5798e454> (a java.lang.ref.Reference$Lock)
- locked <0x5798e454> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:502)
at java.lang.ref.Reference.tryHandlePending(Reference.java:191)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:153)
Finalizer id=3 state=WAITING
- waiting on <0x230ea8c8> (a java.lang.ref.ReferenceQueue$Lock)
openapi: 3.0.1
info:
title: swagger-server
description: My API
license:
name: Apache 2.0
version: "0.1"
paths:
/lineupcacheservice/cache/clear/{type}:
delete:
@RaviH
RaviH / pom.xml
Created October 7, 2018 02:13
maven pom.xml that works with Java and Groovy code in microanut service project.
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>micronaut.ribbon.example2</groupId>
<artifactId>micronaut-ribbon-example2</artifactId>
<version>0.1</version>
<properties>
<exec.mainClass>micronaut.ribbon.example2.Application</exec.mainClass>
<micronaut.version>1.0.0.RC1</micronaut.version>
<jdk.version>1.8</jdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@RaviH
RaviH / JacksonObjectMapperListOfElementsJson.groovy
Created January 20, 2016 21:40
Example of how to deserialize json that starts with an array.
package com.charter.aesd.activationlogin.edge.service
import com.charter.aesd.hystrix.utils.aws.CommandBuilderFactory
import com.fasterxml.jackson.databind.ObjectMapper
import groovy.json.JsonSlurper
import groovy.transform.ToString
/**
* Created by rhasija on 1/20/16.
*/
@RaviH
RaviH / JsonToObject.groovy
Last active January 15, 2016 21:56
Gist to convert Json string to a specific object type
package com.charter.aesd.activationlogin.edge.rest
import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
import groovy.transform.ToString
/**
* Created by rhasija on 1/15/16.
*/
class JsonToObject {
@RaviH
RaviH / DefaultIfEmptyObservableExample.groovy
Created January 14, 2016 17:09
Example of defaultIfEmpty Observable example.
package com.charter.aesd.activationlogin.edge.service
import rx.Observable
import rx.functions.Func1
import rx.functions.Func3
/**
* Created by rhasija on 1/14/16.
*/
class ObsTest {
@RaviH
RaviH / SwitchIfEmptyObservableExample.groovy
Created January 14, 2016 17:08
Switch If Empty Observable example
package com.charter.aesd.activationlogin.edge.service
import rx.Observable
import rx.functions.Func1
import rx.functions.Func3
/**
* Created by rhasija on 1/14/16.
*/
class ObsTest {
@RaviH
RaviH / CollectionsUtilsSelectExample.java
Created November 3, 2015 22:31
CollectionUtils example for intersect using select and selectRejected.
package com.charter.aesd.account.core.query;
import com.charter.aesd.device.domain.Device;
import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;