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
#!/usr/bin/env python3 | |
""" | |
Binary Indexed Tree / Fenwick Tree | |
https://www.hackerearth.com/practice/notes/binary-indexed-tree-made-easy-2/ | |
https://www.topcoder.com/community/data-science/data-science-tutorials/binary-indexed-trees/ | |
https://www.youtube.com/watch?v=v_wj_mOAlig | |
https://www.youtube.com/watch?v=kPaJfAUwViY | |
""" |
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
""" | |
Snake Eater | |
Made with PyGame | |
""" | |
import pygame, sys, time, random | |
# Difficulty settings | |
# Easy -> 10 |
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
import java.util.*; | |
import java.lang.*; | |
import java.io.*; | |
class ShortestDistanceBetweenTwoCells { | |
static class Cell { | |
int row; |
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
import java.io.*; | |
import java.lang.*; | |
import java.util.*; | |
class nBitGrayCode { | |
public static void main(String[] args) { | |
int n = 3; | |
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
import java.util.*; | |
import java.lang.*; | |
import java.io.*; | |
class Sakamoto { | |
static int sakamotoAlgorithm(int date, int month, int year) { | |
int[] dateDiff = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}; |
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
#!/usr/bin/env python3 | |
def is_safe(x, y, matrix, visited): | |
col = len(visited[0]) | |
row = len(visited) | |
if x >= 0 and y >= 0 and x < col and y < row and visited[y][x] == False and matrix[y][x] == 1: | |
return True | |
else: |
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
import java.util.*; | |
import java.io.*; | |
import java.lang.*; | |
public class kSwapLargestPermutation { | |
public static void main(String[] args) { | |
Integer[] numberArray = new Integer[] {4, 5, 2, 1, 3}; |
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
import java.io.*; | |
import java.math.*; | |
import java.util.*; | |
import java.lang.*; | |
public class StreamMedian { | |
public static void main(String[] args) { |
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
#!/usr/bin/env python3 | |
import math | |
def main(): | |
# take inputs | |
string = input("Enter the text to be justified:\n").split() | |
width = int(input("Enter the width of the line: ")) | |
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 kmp(txt, pat): | |
# base conditions | |
if len(pat) == len(txt): | |
if pat == txt: | |
return 0 | |
else: | |
return -1 | |
if len(pat) > len(txt): | |
return -1 | |
if len(pat) == 0 or len(txt) == 0: |
NewerOlder