Coder Social home page Coder Social logo

coding-challenges's Introduction

Coding Challenges

1st Challenge

Create a function that receives an integers array and returns the number that appeared only once.

Input Output
(2,4,6,4,9,6,2) 9
(1,1,2) 2
(2,2,1) 1

2nd Challenge

Create a function that receives a string then it converts uppercase letters into lowercase and vice versa. The function then should print the converted value.

Input Output
Hello hELLO
Hi hI
Hello World hELLO wORLD
My name is Ali mY NAME IS aLI
sHroog ShROOG

3rd Challenge

Create a function that receives an array of items & arrays and returns one flattened array with all items exluding null values.

N Input Output
1 [1,[2,3,null,4],[null],5] [1,2,3,4,5]
2 [7, 0,[null],[null, null, 9]] [7, 0, 9]
3 [[null, 3], [2, 4, 5, null], 0, 8, 3] [3, 2, 4, 5, 0, 8, 3]
4 [3, 5, [5, 9, 0]] [3, 5, 5, 9, 0]

4th Challenge

Create a function that receives a string that contains combination of parentheses, square brackets, and curly braces. Then, it returns true if every opening bracket has a closing pair.

Input Output
}{ false
() true
)({} false
({ }}) false
({ }) true
{{()}} true
{{()} false
[{}] true
{[(}]) true
{[}]) false

=============== // MARK: Belal Ahmad Dohal // Swift

//Q1).Create a function that receives an integers array and returns the number that appeared only once. func getOnlyOneNumber(arr:[Int]) -> [Int] { var singleNumbers = Int:Int var result = Int for i in arr { singleNumbers[i] = i } for i in singleNumbers { result.append(i.key) } return result } //Q2).Create a function that receives a string then it converts uppercase letters into lowercase and vice versa. The function then should print the converted value. func printConvertString(str:String) { var result = "" for i in str { if i.isLowercase == true { result += i.uppercased() }else { result += i.uppercased() } } print(result) } //Q3).Create a function that receives an array of items & arrays and returns one flattened array with all items exluding null values. func noNull(arr:[Any]) -> [Any] { var result = Any for i in arr { if let num = i { result.append(num) } } return result } //Q3).Create a function that receives a string that contains combination of parentheses, square brackets, and curly braces. Then, it returns true if every opening bracket has a closing pair.

coding-challenges's People

Contributors

ihadabs avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.