This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TwoSum { | |
public static void main(String[] args) { | |
int[] array = { -9, -6, 0, 1, 2, 7, 11, 15, 20, 35, 47}; | |
System.out.println(Arrays.toString(twoSum(array, 100))); | |
} | |
public static int[] twoSum(int[] arr, int target) { | |
Map<Integer, Integer> map = new HashMap<>(); | |
for (int i = 0; i < arr.length; i++) { | |
if (map.containsKey(target - arr[i])) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int add(int x, int y){ return x + y; } | |
int multiply(int x, int y){ return x * y; } | |
int subtract(int x, int y){ return x - y; } | |
int divide(int x, int y){ return x / y; } | |
typedef int (*arithmeticFcn)(int, int); | |
struct arithmeticStruct |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <array> | |
#include <cstring> | |
#include <cstdlib> | |
#include <ctime> | |
// перечисление для достоинств карт | |
enum CardRank | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
struct Students | |
{ | |
std::string name; | |
int grade; | |
}; | |
void sortNames(Students *students, int length) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. | |
https://github.com/alexey-goloburdin/typed-python-book |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def binary_search(lst, item): | |
low = 0 | |
high = len(lst) - 1 | |
while low <= high: | |
mid = (low + high) // 2 | |
guess = lst[mid] | |
if guess == item: | |
return mid | |
if guess > item: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def quicksort(arr): | |
if len(arr) < 2: | |
return arr | |
else: | |
pivot = arr[0] | |
less = [i for i in arr[1:] if i < pivot] | |
greater = [i for i in arr[1:] if i > pivot] | |
return quicksort(less) + [pivot] + quicksort(greater) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def findSmallest(arr): | |
smallest = arr[0] | |
smallest_idx = 0 | |
for i in range(1, len(arr)): | |
if arr[i] < smallest: | |
smallest = arr[i] | |
smallest_idx = i | |
return smallest_idx | |