This file contains hidden or 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
package linked_lists | |
fun main() { | |
val myLinkedList = LinkedList<String>() | |
myLinkedList.append("Alice") | |
myLinkedList.append("Bob") | |
myLinkedList.append("Claire") | |
myLinkedList.append("Claire") | |
myLinkedList.append("David") |
This file contains hidden or 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
package arrays_and_strings | |
import java.lang.StringBuilder | |
fun main() { | |
val firstString = readln() | |
val secondString = readln() | |
println(compareValues(firstString.toCharArray(), secondString.toCharArray())) |
This file contains hidden or 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
fun main() { | |
val inputStringValue = "Mr John Smith " | |
replaceEmptySpaces(inputStringValue).forEach { print(it) } | |
} | |
fun replaceEmptySpaces(stringValue: String): CharArray { | |
val characters = arrayOf('%', '2', '0') | |
val charArray = stringValue.toCharArray() |
This file contains hidden or 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
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
} | |
} |
This file contains hidden or 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
fun main() { | |
val numbers = listOf(7, 3, 9, 1, 4, 8, 6, 2, 10, 5).sorted() | |
val binaryTree = BinaryTree<Int>() | |
println(drawTreeDiagram(generateBinarySearchTree(numbers))) | |
binaryTree.inOrderTraversal(generateBinarySearchTree(numbers)) { | |
println(it) | |
} |
This file contains hidden or 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
/** CRACKING THE CODE INTERVIEW | |
* 2.1 Remove Dups.: Write code to remove duplicates from an unsorted linked list. | |
* How would you solve this problem if a temporary buffer is not allowed? */ | |
data class Node<T>(var value: T, var next: Node<T>? = null) { | |
override fun toString(): String { | |
if (next == null) return "$value" | |
return "$value -> ${next.toString()}" | |
} | |
} |
This file contains hidden or 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
fun main() { | |
val intNumber: Int = 1_000_000 | |
val byteNumber: Byte = intNumber.toByte() | |
val numberOfStudents = 50 | |
getStudents(numberOfStudents) | |
showMessage(token = "token_0000") |
This file contains hidden or 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
/** | |
This question is asked by Google. Given two integer arrays, return their intersection. | |
Note: the intersection is the set of elements that are common to both arrays. | |
Ex: Given the following arrays... | |
nums1 = [2, 4, 4, 2], nums2 = [2, 4], return [2, 4] | |
nums1 = [1, 2, 3, 3], nums2 = [3, 3], return [3] | |
nums1 = [2, 4, 6, 8], nums2 = [1, 3, 5, 7], return [] | |
*/ |
This file contains hidden or 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
/** | |
This question is asked by Google. Given two integer arrays, return their intersection. | |
Note: the intersection is the set of elements that are common to both arrays. | |
Ex: Given the following arrays... | |
nums1 = [2, 4, 4, 2], nums2 = [2, 4], return [2, 4] | |
nums1 = [1, 2, 3, 3], nums2 = [3, 3], return [3] | |
nums1 = [2, 4, 6, 8], nums2 = [1, 3, 5, 7], return [] | |
*/ |
This file contains hidden or 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
# Data import | |
tubos = read.csv("tubos-circulares.csv") | |
# Data split | |
tubos.espessura = tubos[,2] | |
tubos.resistencia = tubos[,3] | |
# Plot graph | |
plot(tubos.espessura, tubos.resistencia, pch = 19, col = "orange", xlab = "Espessura das calotas (mm)", ylab = "Resistência (kN)", main = "Espessura e Resistência de Calotas") | |
abline(h = mean(tubos.resistencia), col = "blue", lty = 2) |
NewerOlder