Skip to content

Instantly share code, notes, and snippets.

View gladimdim's full-sized avatar
💭
Unreal Engine

Dmytro Gladkyi gladimdim

💭
Unreal Engine
View GitHub Profile
/// https://www.hackerrank.com/challenges/minimum-swaps-2/
///
/// You are given an unordered array consisting of consecutive integers [1, 2, 3, ..., n] without any duplicates.
/// You are allowed to swap any two elements. Find the minimum number of swaps required to sort the array in ascending order.
int minimumSwaps(List<int> input) {
int swaps = 0;
var list = List.generate(input.length, (index) => index + 1);
var map = {};
for (var el in list) {
/// Task
/// Given a set of closed intervals, find the smallest set of numbers that covers all the intervals. If there are multiple smallest sets, return any of them.
Set findMinSetToCoverIntervals(List<List<int>> input) {
var start;
var end;
/// we need to find minimum value of the end intervals, it will be our start in result
/// and maximum value of the start intervals, it will be our end in result
for (List<int> interval in input) {
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
import 'dart:async';
void main() async {
print('a');
await waitTime(Duration(seconds: 3));
print('b');
}
Future waitTime(Duration duration) {
Completer completer = Completer();
void main() {
findIfSumIsInArray();
}
/**
Given a list of numbers and a number k, return whether any two numbers from the list add up to k.
For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17.
class Node {
Node? left;
Node? right;
int value;
Node({required this.value, this.left, this.right});
}
/*
Given a binary tree, return the level of the tree with minimum sum.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
@gladimdim
gladimdim / linkedpagesviews.dart
Last active January 23, 2020 13:10
Two PageViews connected with buttons and scroll callbacks.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
import 'package:flutter/material.dart';
import 'dart:ui' as ui;
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
const double APP_BAR_HEIGHT = 40.0;
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
import 'package:flutter/material.dart';
class TextEditor extends StatefulWidget {
final String text;
final int maxLines;
final Function(String) onSave;
final Function(String) onSubmitted;
final TextEditingController controller;
final bool showDone;