This file contains hidden or 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
# * Generate 10-digit time-based one time password conforming to RFC6238 TOTP. | |
# | |
# ** USERID is the email of participant and SECRET is some shared secret. USERID+SECRET is used to generate the | |
# ** SHARED_SECRET which is used at approver end also | |
# | |
import hmac | |
import hashlib | |
import time | |
import sys |
This file contains hidden or 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
#include <iostream> | |
using namespace std; | |
void print_a(int arr[], int start, int end){ | |
/* Utility function to print array */ | |
for(int i = start;i <= end; i++) | |
cout << arr[i] << " "; | |
cout << endl; | |
} |
This file contains hidden or 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
/* | |
A small frog wants to get to the other side of a river. The frog is initially located on one bank of the river (position 0) | |
and wants to get to the opposite bank (position X+1). Leaves fall from a tree onto the surface of the river. | |
You are given an array A consisting of N integers representing the falling leaves. A[K] represents the position where one | |
leaf falls at time K, measured in seconds. | |
The goal is to find the earliest time when the frog can jump to the other side of the river. The frog can cross only when | |
leaves appear at every position across the river from 1 to X (that is, we want to find the earliest moment when all the | |
positions from 1 to X are covered by leaves). You may assume that the speed of the current in the river is negligibly small, |
This file contains hidden or 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
/* | |
You are given N counters, initially set to 0, and you have two possible operations on them: | |
increase(X) − counter X is increased by 1, | |
max counter − all counters are set to the maximum value of any counter. | |
A non-empty array A of M integers is given. This array represents consecutive operations: | |
if A[K] = X, such that 1 ≤ X ≤ N, then operation K is increase(X), | |
if A[K] = N + 1 then operation K is max counter. | |
For example, given integer N = 5 and array A such that: |
This file contains hidden or 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
/* | |
A non-empty array A consisting of N integers is given. | |
A permutation is a sequence containing each element from 1 to N once, and only once. | |
For example, array A such that: | |
A[0] = 4 | |
A[1] = 1 | |
A[2] = 3 |
This file contains hidden or 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
/* | |
Write a function: | |
int solution(int A, int B, int K); | |
that, given three integers A, B and K, returns the number of integers within the range [A..B] that are divisible by K, i.e.: | |
{ i : A ≤ i ≤ B, i mod K = 0 } | |
For example, for A = 6, B = 11 and K = 2, your function should return 3, because there are three numbers divisible by 2 |
This file contains hidden or 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
<?php | |
/** | |
Define the classes and their methods (including parameters and return types) for a system that consist of a bookshelf, | |
books, magazines, and notebooks. The bookshelf should allow store and retrieval of the items as well as reporting on the | |
state of the bookshelf (how many items it has, how many more items it can hold) and initializing the capacity (in number | |
of items it can hold in total). The other items should allow reading of a single page given the page number that returns | |
the text of the page. A book has an accessible title and author. A magazine has an accessible name. A notebook has an | |
accessible owner. | |
*/ | |
abstract class BookShelfFactory{ |
This file contains hidden or 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
#include <iostream> | |
#include <bits/stdc++.h> | |
using namespace std; | |
/** | |
* Check if string is balanced using stack DataStructure | |
*/ | |
bool isBalanced(string s){ | |
char c; | |
int n = s.length(); |
This file contains hidden or 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
/** | |
* Program to find all the factors of given Number N | |
*/ | |
#include <iostream> | |
#include <bits/stdc++.h> | |
using namespace std; | |
int main(int argc, char* argv[]){ | |
// int N = 2147483643; |
This file contains hidden or 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
/** | |
* Program to make a tree structure with Pre-order, Post-order & In-order traversal | |
*/ | |
#include <iostream> | |
#include <bits/stdc++.h> | |
using namespace std; | |
class Node { | |
public: |