Models | Examples |
---|---|
Display ads | Yahoo! |
Search ads |
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
""" Quicksort implementation """ | |
def quicksort(arr): | |
""" Quicksort a list | |
:type arr: list | |
:param arr: List to sort | |
:returns: list -- Sorted list | |
""" |
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
/* You are given an integer N. Find the digits in this number that exactly divide N and display their count. | |
For N = 24, there are 2 digits - 2 & 4. Both these digits exactly divide 24. So our answer is 2. */ | |
#include<iostream> | |
#include<string> | |
using namespace std; | |
int main(){ |
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
/* The Utopian tree goes through 2 cycles of growth every year. The first growth cycle occurs during the spring, | |
when it doubles in height. The second growth cycle occurs during the summer, when its height increases by 1 meter. | |
Now, a new Utopian tree sapling is planted at the onset of the spring. Its height is 1 meter. Can you find the | |
height of the tree after N growth cycles? */ | |
#include<iostream> | |
#include<vector> | |
using namespace std; |
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
/* Shashank likes strings in which consecutive characters are different. For example, | |
he likes ABABA, while he doesn't like ABAA. Given a string containing characters A and | |
B only, he wants to change it into a string he likes. To do this, he is allowed to | |
delete the characters in the string. | |
Your task is to find the minimum number of required deletions. */ | |
#include<iostream> | |
#include<string> |
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
/* Watson gives two integers A & B to Sherlock and asks if he can count the number | |
of square integers between A and B (both inclusive). | |
A square integer is an integer which is the square of any integer. For example, 1, | |
4, 9, 16 are some of the square integers as they are squares of 1, 2, 3, 4 respectively. | |
Input Format | |
First line contains T, the number of testcases. T test cases follow, each in a newline. | |
Each testcase contains two space separated integers denoting A and B. |
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
//Print the odd numbers from 1 to 99. | |
#include<iostream> | |
using namespace std; | |
int main(){ | |
for (int i = 1; i < 100; i++){ |
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
//Print out the sum of integers read from a file. | |
#include<iostream> | |
using namespace std; | |
int main(){ | |
int sum = 0, n; | |
while (cin >> n){ |
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
#include<iostream> | |
#include<string> | |
#include<stdlib.h> | |
using namespace std; | |
int isLetter(int sasi); | |
//Tests to see if the character is a letter | |
int isUpper(int sasi); |
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
//Change all letters to lower case | |
#include<iostream> | |
#include<string> | |
#include<cstdlib> | |
using namespace std; | |
int main(){ | |
string str; |
OlderNewer