Skip to content

Latest commit

 

History

History
41 lines (34 loc) · 1.92 KB

File metadata and controls

41 lines (34 loc) · 1.92 KB

Scracthpad - ideas

Evaluation implemented for Java, Js and Py. Add Kotlin??

Integers:

  • getFactorial(num: int): int
  • getAbsoluteDifference(num1: int, num2: int): int
  • getOppositeValue(num: int): int (if the val is 6, return -6, if the val is -4, return 4 etc...)
  • getSqrSum(nums: int[]) int (calc square of the sum of all members of the array and return)
  • enoughSpace(cap: int, onboard: int, waiting: int): int (if there's enough space on bus, return 1, else return neg capacity (e.g. -2))

Arrays:

  • getProduct(nums: int[]): int
  • average(nums: int[]): float
  • containsOddNumber(nums: int[]): boolean
  • isSequence(nums: int[]): boolean
  • dominantMember(nums: int[]): int
  • hasDuplicates(nums: int[]) : boolean
  • minMax(nums: int[]) : int[] (return the min and max values from the array [-2, 5])

String:

  • isPalindrome(str: string): boolean
  • isAllSameCase(str: string): boolean
  • happyOrSad(sentence: string, happyWords: string[], sadWords: string[]) string (return "Happy" if there are more happy words than sad words, else "Sad")
  • anyContainIllegalChars(candidateStrings: string[], illegalChars: string): boolean
  • isIsogram(str: string): boolean (An isogram contains only unique letters. No duplicates. Ignore casing.)
  • camelToSnake(str: string): string (convert camelCase to snake case, i.e someVariableName to some_variable_name)
  • sanitiseInput(str: string): string (remove html tags and return, i.e

    'Hello world'

    -> 'Hello world')
  • crossSiteScriptFilter(str: string): string (you're programming a social media app. Remove script injection attempts from submissions)

Lists/Sets:

  • isPangram(str: string): boolean (does the string contain all letters of the alphabet? ignore case)
  • findOddOccurance(int[] nums): int

Boolean:

  • isHungry(name: string): boolean (return true if name begins with H or h)
  • countSheep(sheeps: boolean[]) int (return how many sheep are in a pen. true means the sheep is there.)

Functions/methods: