Skip to content

Instantly share code, notes, and snippets.

View arjrr's full-sized avatar

Arilson arjrr

View GitHub Profile
/*
UBER
Description of Question
The goal is to write a function which takes a
list of string items and returns a list containing
unique items sorted based on their frequency in descending order
Example:
input = I -> am -> happy -> so -> I -> sing -> happy -> happy -> songs
output = happy -> I -> am -> so -> sing -> songs
/**
* In this chapter, you’ll learn about the Big O notation for the different levels of scalability in two dimensions:
* • Execution time.
* • Memory usage.
*/
fun main() {}
/** Constant time *
* A constant time algorithm is one that has the same running time regardless of the size of the input.
/**
* This question is asked by Amazon. Given a string representing the sequence of moves a robot vacuum makes,
* return whether or not it will return to its original position. The string will only contain L, R, U, and D characters,
* representing left, right, up, and down respectively.
*
* Ex: Given the following strings...
*
* "LR", return true
* "URURD", return false
* "RUULLDRD", 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()!!
/**
* 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, 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 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"
*
*/
struct node {
int value;
struct node *next;
};
data class Node(var value: String, var next: Node? = null)
class LinkedList {
private var head: Node? = null
private var tail: Node? = null
private var size = 0
fun isEmpty(): Boolean {
return size == 0
}
}