Skip to content

pprraasshhaanntthh/HackerRankSolutions

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HackerRankSolutions

Language Build Status

This is a repo for HackerRank Solutions in Swift

Different folders are named after corresponding domain names or contest names.

Problem Time Space Difficulty Tag Note
Angry Professor O(n) Easy Implementation
SherlockAndTheBeast O(n) Easy Implementation
Utopian Tree O(n) Easy Implementation
Find Digits O(n) Easy Implementation
Funny String O(n) Easy String
Pangrams O(n) O(1) Easy String
Alternating Characters O(n) O(1) Easy String
Game of Thrones O(n) O(1) Easy String
Make it anagram O(n) O(1) Easy String
Anagram O(n) O(1) Easy String
Two Strings O(n) O(1) Moderate String Set
SherlockAndAnagrams O(n^3lgn) O(n^2) Moderate String Sort, Dictionary, Permutation
Palindrome Index O(n) O(1) Easy String
Sherlock And Valid String O(n) O(1) Difficult String Dictionary
The Maximum Subarray O(n) O(n) Easy Dynamic Programming
The Coin Change Problem O(MN) O(MN) Medium Dynamic Programming bottom-up table construction
Knapsack O(MN) O(MN) Moderate Dynamic Programming memoization in swift
The Longest Increasing Subsequence O(N^2) O(N) Advanced Dynamic Programming time out
Sherlock and Cost O(N) O(N) Moderate Dynamic Programming
Hexagonal Gird O(N^2) O(N) Moderate Dynamic Programming recursive solution
Sam and SubStrings O(N) O(N) Moderate Dynamic Programming
Travel Around the World O(N) O(N) Moderate Dynamic Programming validation pass and candidates finding pass
Red John is Back O(N) + O(nlgn) O(N) Moderate Dynamic Programming memoization
Dorsey Thief O(NM) O(NM) Advanced Dynamic Programming

Contests

Data Structures in HackerRankHelper

  • FIFO Queue with Two Arraies
  • FIFO Queue with Listnode
  • ListNode
  • AVLNode
  • AVLTree
  • BinaryIndexedTree

Usage

I created class for each problem. If you want to test those solution on HackerRank, please follow this guideline.

  1. create a constant with class name.

     let mySolution = MyClass()
    
  2. call solution method on that constant

     mySolution.solution()
    
  3. copy and paste related helper methods from HackerRankHelper folder, eg. getLine(), getInt()

Note

All those solution I wrote used Swift1.2, since HackerRank only supports Swift1.* for now. But it is not a big deal since those solutions usually don't need too much new language features.

About

This is a repo for HackerRankSolutions with Swift

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%