Skip to content

Instantly share code, notes, and snippets.

View hoanbka's full-sized avatar
💭
while I < YOU: I++

Hoan Nguyen Van hoanbka

💭
while I < YOU: I++
  • Hanoi, Vietnam
View GitHub Profile
@hoanbka
hoanbka / sales.cpp
Created December 10, 2017 16:12
sales
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
int main(int argc, char const* argv[])
{
double *sale = nullptr,
total = 0,
avarage;
@hoanbka
hoanbka / chessForThree.cpp
Created December 7, 2017 02:44
Chess For Three
#include<iostream>
#include<vector>
using namespace std;
int indexOf(int el, vector<int> v, int sizeOfCandidate){
for(int i=0;i< sizeOfCandidate;i++){
if(v[i]==el) return 0;
}
@hoanbka
hoanbka / greed.cpp
Created December 4, 2017 17:27
cans of cola
#include<iostream>
#include<vector>
using namespace std;
int main() {
long long n;
cin >> n;
vector<long long> a;
vector<long long> b;
@hoanbka
hoanbka / .cpp
Created December 2, 2017 18:17
Chtholly's request
#include <bits/stdc++.h>
using namespace std;
string tostr(int n) {
stringstream s;
string x;
while (n > 0) {
x += (n % 10 + '0');
n /= 10;
/**
* Created by Hoan Nguyen on 11/11/2017.
*/
//Note that: this solution is for array of Intergers ONLY
function diffArray(arr1, arr2) {
var output = [];
// Same, same; but different.
arr1.sort((a, b) => a - b);
/**
* Created by Hoan Nguyen on 11/11/2017.
*/
function reverseString(str) {
return str.split('').reverse().join('');
}
function reverseStrUsingRecursion(str) {
if (str.length === 1) return str[0];
@hoanbka
hoanbka / number-of-islands.js
Created November 9, 2017 17:19
number-of-islands.js
/**
* Created by Hoan Nguyen on 11/9/2017.
*/
/**
* @param {character[][]} grid
* @return {number}
*/
# https://leetcode.com/problems/summary-ranges/description/
class Solution:
def summaryRanges(self, nums):
"""
:type nums: List[int]
:rtype: List[str]
"""
output = []
temp = ""
@hoanbka
hoanbka / summary-ranges.js
Created November 7, 2017 18:26
Summary Ranges
/**
* Created by Hoan Nguyen on 11/8/2017.
* https://leetcode.com/problems/summary-ranges/description/
*
*/
/**
* @param {number[]} nums
* @return {string[]}
*/
@hoanbka
hoanbka / search-for-a-range.js
Created November 7, 2017 17:27
Search for a range in an ascending order array
/**
* Created by Hoan Nguyen on 11/8/2017.
* https://leetcode.com/problems/search-for-a-range/description/
*/
var searchRange = function(nums, target) {
var found = false;
var res = [];
for (var i = 0; i < nums.length; i++) {
if (nums[i] == target) {