Skip to content

Instantly share code, notes, and snippets.

View funyin's full-sized avatar
👨‍💻
Composing and Fluttering

Funyinoluwa Kashimawo funyin

👨‍💻
Composing and Fluttering
View GitHub Profile
@funyin
funyin / Main.kt
Created October 17, 2022 19:19
Spriral Matrix
/**
* Spiral Matrix
* Print all the elements in a matrix by following a spiral clockwise path in a matrix
*
* Input:
* [
* [1 , 2, 3, 4, 5],
* [6 , 7, 8, 9, 10],
* [11 , 12, 13, 14, 15]
* ]
@funyin
funyin / Main.kt
Last active October 17, 2022 00:34
Matrix Zeros
/**
* Given a 2D matrix, if an element is 0 set its entire row and column to 0. Do it in place
*
* Input:
* [[1,1,1,1],
* [1,1,1,0],
* [1,1,1,1]]
*
* Output:
* [[1,1,1,0],
@funyin
funyin / Main.kt
Created October 17, 2022 00:00
Kth largest element
/**
* Find Kth Largest element in an integer array
*/
fun main(){
val array = intArrayOf(1,1,1,2,1,4,1,7,8,4,2,5,9,9,4,7,2,0,4,6,1)
print(array.kTthLargestElement(3))
}
fun IntArray.kTthLargestElement(k: Int): Int {
@funyin
funyin / Main.kt
Last active October 16, 2022 23:51
Rotate Array
/**
* Given an array, rotate the array to the left by k steps where k is non-negative
*
* Input: [1,2,3,4,5,6,7] ans k = 2
* Output: [3,4,5,6,7,1,2]
*/
fun main(){
val array = intArrayOf(1,2,3,4,5,6,7)
val k = 3
print(array.leftShit(k).asList())
@funyin
funyin / Main.kt
Created October 16, 2022 23:05
Reverse words in string
/**
* Given an input string, reverse the string word by word
*
* Input: "reverse words in a string"
* Output: "string a in words reverse"
*/
fun main(){
val words = "reverse words in a string"
print(words.run {
@funyin
funyin / Main.kt
Created October 16, 2022 22:47
Fizz Buzz
//Print numbers from 1 to 100. For multiples of 3 print Fizz instead of the number, for multiples of 5 print Buzz instead of the number
fun main(){
repeat(100){
val builder = StringBuilder()
val number = it+1
val fizzer = number % 3 == 0
if(fizzer)
builder.append("Fizz ")
val buzzer = number % 5 == 0
@funyin
funyin / pr_template.md
Last active September 20, 2022 17:44 — forked from luboganev/pr_template.md
PR template

🎯 Scope

A broad summary of the changes or new functionality that this PR brings.

🛠 Details

A detailed list of changes and new functionality. You can be very technical and specific in this section.

🖼 Screenshots and videos

🧪 Tests

@funyin
funyin / main.kt
Last active September 11, 2022 18:17
Coding challenge - String representation of time in seconds
fun main(){
print(solution(3600))
}
// output: 1h
fun solution(X: Int): String {
var secondsValue = TimeUnit.SECONDS()
var minutesValue = TimeUnit.MINUTES()
var hoursValue = TimeUnit.HOURS()
var daysValue = TimeUnit.DAYS()
@funyin
funyin / app_expansion_panel.dart
Created June 13, 2022 22:03
A fix for flutters expansion panel list. Removed header icon and gap between selected panels
import 'package:flutter/material.dart';
const double _kPanelHeaderCollapsedHeight = kMinInteractiveDimension;
const EdgeInsets _kPanelHeaderExpandedDefaultPadding = EdgeInsets.symmetric(
vertical: 64.0 - _kPanelHeaderCollapsedHeight,
);
class _SaltedKey<S, V> extends LocalKey {
const _SaltedKey(this.salt, this.value);
@funyin
funyin / countries.yml
Created April 12, 2021 15:15 — forked from yrezgui/countries.yml
Hashmap of countries with name as key and iso code as value
Afghanistan: af
Albania: al
Algeria: dz
Andorra: ad
Angola: ao
Antigua and Barbuda: ag
Argentina: ar
Armenia: am
Aruba: aw
Australia: au