Skip to content

Instantly share code, notes, and snippets.

View arjrr's full-sized avatar

Arilson arjrr

View GitHub Profile
class LinkedList {
private var head: Node? = null
private var tail: Node? = null
private var size = 0
fun isEmpty(): Boolean {
return size == 0
}
/** Adding a value at the front of the list. */
/** Removing a value at the front of the list. */
fun pop() {
if (!isEmpty()) size--
head = head?.next
if (isEmpty()) {
tail = null
}
}
/** Adding a value at the front of the list. */
fun push(value: String) {
head = Node(value = value, next = head)
if (tail == null) {
tail = head
}
size++
}
class LinkedList {
private var head: Node? = null
private var tail: Node? = null
private var size = 0
fun isEmpty(): Boolean {
return size == 0
}
}
data class Node(var value: String, var next: Node? = null)
struct node {
int value;
struct node *next;
};
/**
* This question is asked by Apple. Given two binary strings (strings containing only 1s and 0s) return their sum (also as a binary string).
* Note: neither binary string will contain leading 0s unless the string itself is 0.
* Ex: Given the following binary strings...
*
* "100" + "1", return "101"
* "11" + "1", return "100"
* "1" + "0", return "1"
*
*/
/**
* This question is asked by Google. Given a string, return whether or not it uses capitalization correctly.
* A string correctly uses capitalization if all letters are capitalized, no letters are capitalized, or only the first letter is capitalized.
* Ex: Given the following strings...
*
* "USA", return true
* "Calvin", return true
* "compUter", return false
* "coding", return true
*
/**
* This question is asked by Facebook. Given a string, return whether or not it forms a
* palindrome ignoring case and non-alphabetical characters.
*
* Note: a palindrome is a sequence of characters that reads the same forwards and backwards.
*
* Ex: Given the following strings...
* "level", return true
* "algorithm", return false
* "A man, a plan, a canal: Panama.", return true
/**
* This question is asked by Google. Given a string, reverse all of its characters and return the resulting string.
* Ex: Given the following strings...
* “Cat”, return “taC”
* “The Daily Byte”, return "etyB yliaD ehT”
* “civic”, return “civic”
*/
fun main() {
val stringValue = readLine()!!