Skip to content

Instantly share code, notes, and snippets.

View anishLearnsToCode's full-sized avatar
🧙
Unexpected '{' on line 32

Anish Sachdeva anishLearnsToCode

🧙
Unexpected '{' on line 32
View GitHub Profile
import java.util.Scanner;
public class StringBuilderExample {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
StringBuilder builder = new StringBuilder(scanner.nextLine());
builder.append(" hello world");
System.out.println(builder.toString());
}
}
@anishLearnsToCode
anishLearnsToCode / plants-vs-zombies-cheats.json
Created July 21, 2020 18:30
Plants ☘ vs Zombies 💀 Cheats
{
"future": "adds sunglasses to all zombies",
"mustache": "adds mustache to all zombies"
}
@anishLearnsToCode
anishLearnsToCode / BinarySearchEqualOrLarger.java
Created July 17, 2020 16:25
This is the binary search algorithm that returns the position at which an element is found or the position it should be inserted at.
/*
This is the binary search algorithm that returns the position at which an
element is found or the position it should be inserted at if the element is not present.
In other words this algorithm returns position (non conforming in case of duplicates) or the position
of largest element than the one we were searching for if position not found.
*/
class BinarySearch {
private static int search(int[] array, int val) {
@anishLearnsToCode
anishLearnsToCode / hackerrank-skill-tests.md
Last active July 14, 2020 15:58
github.com/anishLearnsToCode +

/hackerrank-java-basic-skill-test /hackerrank-python-basic-skill-test /hackerrank-problem-solving-skill-test /hackerrank-js-basic-skill-test /hackerrank-problem-solving-intermediate-skill-test

@anishLearnsToCode
anishLearnsToCode / hackerrank.md
Last active July 14, 2020 09:11
github.com/anishLearnsToCode +

☕ /hackerrank-java 🐍 /hackerrank-python 👨‍💻 /hackerrank-data-structures 🐱‍💻 /hackerrank-algorithms 🧰 /hackerrank-interview-preparation-kit

@anishLearnsToCode
anishLearnsToCode / pixelate.m
Created July 9, 2020 08:38
This is a MATLAB function that pixelates a given image with parameter w. uses a 2w+1 mask size for blurring.
function W = pixelate(I, w)
[n, m, ~] = size(I);
W = I;
for row = w + 1 : 2 * w + 1 : n + w
for column = w + 1 : 2 * w + 1 : m + w
row_upper = upper(row + w, n, n);
column_upper = upper(column + w, m, m);
sub_image = I(row - w : row_upper, column - w : column_upper, :);
average = mean(mean(sub_image));