Skip to content

Latest commit

 

History

History
39 lines (35 loc) · 1.79 KB

File metadata and controls

39 lines (35 loc) · 1.79 KB

Java Code Practice

Repository to practice Java code Heavily inspired by https://github.com/jwasham/coding-interview-university

Arrays

https://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html

  • Implement an Array List with the following methods:
    • isEmpty() - return true if the list is empty
    • size() - return the number of elements in the list
    • capacity() - return the capacity of the list
    • add(element) - add an element to the end of the list
    • remove(index) - remove an element at the given index
    • get(index) - return the element at the given index
    • set(element, index) - replace an element at the given index

Linked Lists

https://docs.oracle.com/javase/7/docs/api/java/util/LinkedList.html

  • Implement a Doubly Linked List with the following methods:
    • isEmpty() - return true if the list is empty
    • size() - return the number of elements in the list
    • add(element, index) - add an element at the specified index
    • addFirst(element) - add an element at the beginning of the list
    • addLast(element) - add an element at the end of the list
    • remove(index) - remove an element at the specified index
    • removeFirst() - remove the first element in the list
    • removeLast() - remove the last element in the list
    • getFirst() - return the first element in the list
    • getLast() - return the last element in the list
    • get(index) - return the element at the given index
    • set(element, index) - replace an element at the given index

Data Structures practice problems

Taken from UC San Diego Coursera course

  • Check brackets in code [Stack]
  • Extending stack interface [Stack]
  • Network packet processing [Queue]
  • Maximum sliding window [Stack/Queue]
  • Compute tree height [Tree]