Skip to content

Instantly share code, notes, and snippets.

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

Hoan Nguyen hoanbka

💭
while I < YOU: I++
  • Hanoi, Vietnam
View GitHub Profile
# Given a 2D board and a word, find if the word exists in the grid.
#
# The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once.
#
# For example,
# Given board = [
# ['A','B','C','E'],
# ['S','F','C','S'],
# ['A','D','E','E']
# ]
def generateParenthesis(n):
list = []
backtrack(list, "", 0, 0, n)
return list
def backtrack(list, str, open, close, max):
if (len(str) == max * 2):
list.append(str)
return
def solve(str):
standardStr = 'hackerrank'
i = 0
count = 0
for j in str:
if j == standardStr[i]:
i += 1
count += 1
if count == len(standardStr):
@hoanbka
hoanbka / js
Created August 31, 2017 06:19
sherlock-and-valid-string
/*https://www.hackerrank.com/challenges/sherlock-and-valid-string?h_r=next-challenge&h_v=zen*/
function isValid(str){
// Complete this function
var map = new Map();
for(var i=0; i < str.length;i++){
if(map.has(str.charAt(i))){
map.set(str.charAt(i),map.get(str.charAt(i))+1);
INSERT INTO black_list.dbo.Block_list_4G
SELECT ANI,
GETDATE(),
0
FROM cskh_hds.dbo.t_Termination_Call_Detail
where CallDispositionFlag =1 and DateTime >=dateadd(day,datediff(day,0,GETDATE()),0)
and Variable5 is not NULL and AgentPeripheralNumber is not NULL
group by ANI having count(ANI) >=10
UNION
@hoanbka
hoanbka / bomber.java
Created June 13, 2017 04:57
bomber - Google Interview
package code_fight;
/**
* Created by Hoan Nguyen on 6/10/2017.
* https://codefights.com/interview/d8oFgW9dnFgTrfhsX/companies/N3sScnJbzdPDQaHPj
*/
public class bomber {
static int bomber(char[][] field) {
int max = 0;
if (field.length == 0) {
@hoanbka
hoanbka / singleNumber.java
Created March 20, 2017 07:44
singleNumber
package code_fight;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
/**
* Created by Hoan Nguyen on 3/15/2017.
*/
/**
* Created by Albert Hoan on 2/28/2017.
*/
function solveSudoku(board) {
if (board == null || board.length == 0)
return;
solve(board);
}
@hoanbka
hoanbka / SumNumbers.js
Created March 1, 2017 06:50
Sum of numbers in a string
/**
* Created by Albert Hoan on 2/27/2017.
*/
//input: str = '123abc4xyz' => output: sum=123+4=127
//input: str= '1abc34' => output= 35;
function decodeNumber(str) {
@hoanbka
hoanbka / CalculateSizeFolder.py
Created January 24, 2017 08:38
Calculate the size of the folder using Python
import os
res = []
def readFolder(file):
if os.path.isfile(file):
res.append(os.path.getsize(file))
else:
arr = os.listdir(file)
for element in arr: