Skip to content

Latest commit

 

History

History
53 lines (39 loc) · 2.29 KB

README.md

File metadata and controls

53 lines (39 loc) · 2.29 KB

OverView

My intention for this repo is to do and showcase some programming challenges. I think it may help the new programmers and also who is trying to learn programs. I am welcomming your contributions also. Now I am doing this programming challenges in swift. You can expect the same implementation in different langages like c, c++, js etc

challenges

Total number of pairs in an array Write a function to accept an integer array. Write a logic to find out the total number of pair numbers in the array.

  • expectation:

      func findTotalPairs(ar: [Int]) -> Int
    • input: a = [1, 2, 3, 4, 3, 2, 1]
    • output: 3
  • constraints:

    • 0 < ar.count <= n

    refer the code

Find the minimum absolute length between the two elements in an array An array contains a number of strings, it may repeat. Write an algorithm to find out the minimum absolute length between the two strings.

  • expectation:

      func getMinimumDistance(_ strArray: [String], _ firstString: String, _ secondString: String) -> Int
    • input: strArray = ["Apple", "Apple", "Staberry", "Plum","Mango", "Tomato", "Magostine", "Mango", "Apple"], firstString = "Mango", secondString = "Apple"
    • output: 1

    refer the code

Find the unique and common item from two array of keyvalue pairs An array contains dictionries, dictionary contains two keys name and id. But at the time of copmarison yiu have to consider the name only

  • expectation:

      func getMinimumDistance(_ strArrlet a ay: [String], _ firstString: String, _ secondString: String) -> Int
    • input: let a = [["id":"1","name":"Albin"],["id":"2","name":"Anu"],["id":"3","name":"Arsha"]], let b = [["id":"1","name":"Albin"],["id":"2","name":"Anu"]]
    • output: common: [["id": "1", "name": "Albin"], ["name": "Anu", "id": "2"]], unique:[["id": "3", "name": "Arsha"]]

    refer the code