Skip to content

Instantly share code, notes, and snippets.

View arjrr's full-sized avatar

Arilson arjrr

View GitHub Profile
@arjrr
arjrr / RemoveDups.kt
Last active August 4, 2023 15:08
[Linked Lists] Remove dups
package linked_lists
fun main() {
val myLinkedList = LinkedList<String>()
myLinkedList.append("Alice")
myLinkedList.append("Bob")
myLinkedList.append("Claire")
myLinkedList.append("Claire")
myLinkedList.append("David")
package arrays_and_strings
import java.lang.StringBuilder
fun main() {
val firstString = readln()
val secondString = readln()
println(compareValues(firstString.toCharArray(), secondString.toCharArray()))
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()
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}
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)
}
/** 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()}"
}
}
fun main() {
val intNumber: Int = 1_000_000
val byteNumber: Byte = intNumber.toByte()
val numberOfStudents = 50
getStudents(numberOfStudents)
showMessage(token = "token_0000")
/**
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 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 []
*/
# 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)