Skip to content

Instantly share code, notes, and snippets.

View stdk's full-sized avatar

Victor stdk

  • Larch Networks
  • Kiev
View GitHub Profile
def create_map(heights):
max_height = max(heights)
return '\n'.join(''.join('##' if i >= h else ' ' for i in heights)
for h in range(max_height, 0, -1))
def method_a(heights):
water = 0
left = 0
right = len(heights) - 1
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/signalfd.h>
#include <sys/select.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/param.h> //for MAX
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/signalfd.h>
#include <sys/select.h>
#include <sys/param.h> //for MAX
typedef struct custom_popen_data {
int pid;
fd_set active_fd_set,read_fd_set;
FD_ZERO(&active_fd_set);
FD_SET(adapter,&active_fd_set);
FD_SET(STDIN_FILENO,&active_fd_set);
while(1) {
struct timeval timeout = {1,0};
read_fd_set = active_fd_set;
cmake_minimum_required(VERSION 2.6)
project (algs)
set (CMAKE_BUILD_TYPE Release)
set (SRC src)
set (INC inc)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
#include <string>
#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <random>
#include <algorithm>
#include <tuple>
#include <cstdint>
#include <string>
#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <random>
#include <algorithm>
#include <tuple>
#include <cstdint>
#define NUL 000 /* null */
#define SOH 001 /* start of header */
#define EOT 004 /* end of transmission */
#define ACK 006 /* acnowledge */
#define BS 010 /* backspace */
#define TAB 011 /* tab */
#define CR 015 /* carriage return */
#define LF 012 /* line feed */
#define NAK 025 /* no acnowledge */
#define CAN 030 /* cancel */
#include <iostream>
#include <iomanip>
#include <iterator>
#include <vector>
#include <algorithm>
#include <memory>
#include <chrono>
#include <functional>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>
#include <tuple>
#include <stdint.h>
uint64_t merge(int *a, size_t a_len, int *b, size_t b_len) {
int *copy = new int[a_len + b_len];
int *a_end = a + a_len;