Skip to content

Instantly share code, notes, and snippets.

View nderkach's full-sized avatar
✏️

Nikolay Derkach nderkach

✏️
View GitHub Profile
### Keybase proof
I hereby claim:
* I am nderkach on github.
* I am nderkach (https://keybase.io/nderkach) on keybase.
* I have a public key ASDzaBmzYWD5ZUcgOm4QY55kAjO3rA8NLqic3-KvhsHBzgo
To claim this, I am signing this object:
UIWindow *window = [[UIWindow alloc] initWithFrame:rootWindow.bounds];
window.hidden = NO;
window.windowLevel = UIWindowLevel_Background;
window.opaque = YES;
window.backgroundColor = UIColor.ows_materialBlueColor;
ScreenLockViewController *viewController = [ScreenLockViewController new];
viewController.delegate = self;
window.rootViewController = viewController;
@nderkach
nderkach / bit_array_sort.swift
Created September 28, 2019 16:35
Sort a Bit Array
# Sort a Bit Array
func bitSort(_ arr: inout [Int]) {
var zerosCount = arr.filter { $0 == 0 }.count
var idx = 0
while idx < arr.count {
arr[idx] = zerosCount > 0 ? 0 : 1
zerosCount -= 1
idx += 1
@nderkach
nderkach / sorted_bit_array_num_ones.swift
Last active September 28, 2019 17:18
Given a sorted bit array (values of either 0 or 1), determine the number of 1’s in the array.
//Given a sorted bit array (values of either 0 or 1), determine the number of 1’s in the array.
//
//Perform this in O(log(N)) time complexity.
//
//Input: [0,0,0,1,1,1,1,1,1,1,1]
//
//Output: 8
func numOnes(_ arr: [Int]) -> Int {