T

@thang_nguyen

Find a number in an array for which sum of all elements to its left= sum of all elements to its righ

C
3 years ago
/* Include lib */ #include <stdio.h> /* Define */ #define ARRAY_MAX 16 #define ARRAY_INPUT { 0, 1, 2, 3, 4, 5, 6, 25, 29, 9, 10, 11, 12, 13, 14, 15 } int array_input[ARRAY_MAX] = ARRAY_INPUT; /* API */

reverse an array

C
3 years ago
/* Include lib */ #include <stdio.h> /* Define */ #define ARRAY_MAX 15 #define ARRAY_INPUT { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 } //, 15 } int array_input[ARRAY_MAX] = ARRAY_INPUT; /* API reverse array */

Find the number of '5''s in a rolling window of size 10. Flag an error when the count>4

C
3 years ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }

shortest path algorithm: given starting point and destination point in a 2D matrix, get the shortest

C
3 years ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }

recursive function to generate a given sequence

C
3 years ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }

optimized way to generate Fibonacci's sequence

C
3 years ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }

dictionary, swap values

Python
3 years ago
#!usr/bin/python # Import lib import sys import time import os import signal # Sub function def call_help():

Design a 3 bit shift register in verilog RTL ?

C
3 years ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }

delete repeat words

C
3 years ago
/* Include lib */ #include <stdio.h> #include <assert.h> #include <string.h> /* Define */ #define SENTENCE_MAX_WORD 64 #define SENTENCE_MAX_CHAR (SENTENCE_MAX_WORD * 5) char sentence[SENTENCE_MAX_CHAR] = " apple pear plum apple plucot";

Reverse a linked list.

C
3 years ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }

Implement basic logic gates using a MUX and NAND

C
3 years ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }

FSM to check if a number is divided by 5.

C
3 years ago
/* * This request is for VHDL/Verilog. However it can be implemented in C with similar process. * There are some ways to do: * 1. Use Verilog/VHDL. * 2. Use C with similar process Verilog/VHDL. * * 3. If request by C, can use 'x mod 5' to check remainer is 0 or not. * 4. If request by C, can use 'x / 5', then 'result * 5 != x' or not. * 5. If request by C without mod or /, can use 'x - 5' until result < 5 and result 0 or not. */

Implement a LRU cache

C
3 years ago
/* Include lib */ #include <stdio.h> #include <assert.h> /* Max elements for LRU */ #define LRU_MAX_SIZE 4 /* Define LRU cache */ int lru_cache[LRU_MAX_SIZE] = { 0 }; int lru_cache_size = 0;

get all even bits of a number

C
3 years ago
/* Include lib */ #include <stdio.h> #include <assert.h> /* Define */ struct num_info { int cnt_1; int cnt_0; unsigned int new_even_num; };

reverse bits of a number

C
3 years ago
/* Include lib */ #include <stdio.h> #include <assert.h> /* Define */ #define GET_BIT32(num, index) (((num) >> (index)) & 0x1) #define REVERSE_FULL 1 #define REVERSE_PART 0

Search in rotated array

C
3 years ago
/* Include lib */ #include <stdio.h> /* Define */ #define ARRAY_MAX 8 #define ROTATED_SORTED_ARRAY { 0, 1, 2, 3, 4, 5, 6, 7 } #define PIVOT_INDEX 3 #define SEARCH_VAL 0 int rotated_array[ARRAY_MAX] = ROTATED_SORTED_ARRAY;

Power of a number

C
3 years ago
/* Include lib */ #include <stdio.h> #include <assert.h> /* Define */ /* API power of number */ /* Positive power of number: n > 0 */ double positive_power_of_num(double x, int n) {

Reverse words in a sentence

C
3 years ago
/* Include lib */ #include <stdio.h> #include <assert.h> #include <string.h> /* Define */ #define USER_SENTENCE "hello world" #define MAX_STR_CNT 512 /* API Get Sentence size */

Number of 1’s in the binary representation of a number

C
3 years ago
/* Include lib */ #include <stdio.h> #include <assert.h> /* Define */ /* API get number of bit 1 in a number 32 bits */ int get_no_bit1(unsigned int num) { int cnt = 0;

delete repeated element in an array

C
3 years ago
/* Include lib */ #include <stdio.h> #include <assert.h> /* Define */ #define ARRAY_MAX_NUM 8 #define ARRAY_INPUT { 0, 1, 2, 3, 4, 3, 6, 7 } #define ARRAY_INPUT1 { 1, 1, 1, 1, 1, 1, 1, 1 } int array_input[ARRAY_MAX_NUM] = ARRAY_INPUT1;