Skip to content

Instantly share code, notes, and snippets.

View lasverg's full-sized avatar

Nitin Jha lasverg

  • VISA
  • Bangalore, India
  • 14:37 (UTC +05:30)
View GitHub Profile
@lasverg
lasverg / palindrom.js
Created December 13, 2020 04:26
Palindrom: check if input is palindrom | recursive
const isPalRec = (string, start, end) => {
// If there is only one character
if (start === end) {
return true;
}
// If first and last
// characters do not match
if (string[start] !== string[end]) {
return false;
}
@lasverg
lasverg / Staircase.js
Created April 7, 2018 08:29
Staircase | Solution | JavaScript
function staircase(n) {
// Two dimensional array concept
for(let i = 0; i < n; i++){
// Clear the output after each loop
let output = '';
for(let j = 0; j < n; j++){
// Loop through, whenever (n-1-i) is bigger than j concat a space else #
j < (n -1 -i) ? output += ' ': output += '#';
}
console.log(output);
@lasverg
lasverg / diagonal-difference.js
Last active May 29, 2023 06:34
Diagonal Difference | Solution | JavaScript
/*
Diagonal Difference Solution.
sample matrix = [[1,2,3], [4,5,6], [7,8,9]]
*/
function diagonalDifference(matrix) {
// length of input matrix.
const length = matrix.length;
let diagonal1 = 0, diagonal2 = 0;
// Looping through the array and summing the diagonals.
@lasverg
lasverg / bandClock.js
Created November 7, 2015 03:54
BandClock - JQuery Plugin
/*
Band Clock is a jquery plugin to display a dynamic band clock.
Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
Built on top of the jQuery library (http://jquery.com)
@source: http://github.com/zaniitiin/band-clock/
@autor: Nitin Jha
@version: 1.0
*/
(function($) {