Skip to content

Instantly share code, notes, and snippets.

View ankitwww's full-sized avatar
🏠
Working from home

Ankit Kashyap ankitwww

🏠
Working from home
View GitHub Profile

[Don't comment your code here - You will be immediately disqualified]

Given an array of sorted numbers and a target sum, find a pair in the array whose sum is equal to the given target.

Write a function to return the indices of the two numbers (i.e. the pair) such that they add up to the given target.

Example 1:

Input: [1, 2, 3, 4, 6], target=6 Output: [1, 3]

[Don't comment your code here - You will be immediately disqualified]

Given an array of positive numbers and a positive number ‘k,’ find the maximum sum of any contiguous subarray of size ‘k’.

Example 1:

Input: [2, 1, 5, 1, 3, 2], k=3 Output: 9 Explanation: Subarray with maximum sum is [5, 1, 3].

Keybase proof

I hereby claim:

  • I am ankitwww on github.
  • I am ankitlst (https://keybase.io/ankitlst) on keybase.
  • I have a public key ASBa0C4P6aEAZ3TMRmXzcHpuD8REvEZugVbont5o0Gcq0go

To claim this, I am signing this object:

Incrementing Integers As A Service

User Story

As a developer, I need a way to get integers that automatically increment so that I can generate identifiers from within my code. I am in a hurry and would like to call a REST endpoint that returns the next available integer so that I can get on with building my feature. Why I need to generate identifiers using sequential integers is not important ;) Suffice it to say that this challenge is based on a real-world scenario.

Your Task

Develop a REST service that:

  1. Allows me to register as a user. At a minimum, this should be a REST

Implement a Queue service in NodeJS/JAVA (or your preferred language). Implement all the features that you think should be supported by a queuing service/message broker, like:

  1. Receive a message.
  2. Store messages.
  3. Send messages to a consumer one-by-one or in bulk when a consumer requests messages.
  4. Acks and Nacks: If the consumer successfully acks the message, the message should get deleted from the queue. When a message is nacked, it should appear back in the queue to be consumed by any consumer immediately.
  5. Visbility timeout: If a consumer gets a message, no other consumer should see that message for Visbility timeout seconds. If the message is nacked/acked by this time, good enough. If not, the message should again be visible.
  6. Deadletter settings: If the message is nacked more than a specified number of times, the message is moved to a dead letter queue.

Also create a library that contains functions to interact with the queue / manage the queue.

"use strict";
// Quick Arguments Shape Adapters
function unary(fn) {
return function one(arg) {
return fn(arg);
};
}
function binary(fn) {
@ankitwww
ankitwww / Simple CSS Checkboxes with Font Awesome.markdown
Created December 17, 2015 06:18
Simple CSS Checkboxes with Font Awesome
@ankitwww
ankitwww / npm-scripts.md
Created November 1, 2015 01:10 — forked from hashrock/npm-scripts.md
awesome-npm-scripts
{
    "build-js": "browserify browser/main.js | uglifyjs -mc > static/bundle.js",
    "build-css": "cat static/pages/*.css tabs/*/*.css",
    "build": "npm run build-js && npm run build-css",
    "watch-js": "watchify browser/main.js -o static/bundle.js -dv",
    "watch-css": "catw static/pages/*.css tabs/*/*.css -o static/bundle.css -v",
    "watch": "npm run watch-js & npm run watch-css",
@ankitwww
ankitwww / gulpfile.js
Created October 31, 2015 17:04 — forked from glenasmith/gulpfile.js
Zip up your webjob files into a deployable artifact
gulp.task('webjob', function() {
var webjob = "feedFetcher.zip";
del(webjob)
return gulp.src(['parsers/*.js', 'package.json', 'feedFetcher.js'], {base: "."})
.pipe(zip(webjob))
.pipe(gulp.dest('.'));
});