본문 바로가기

Algorithm/Code Fights (Code Signal)

Aracade Intro #25 arrayReplace. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar

Aracade Intro #25 arrayReplace. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar


Q.


Given an array of integers, replace all the occurrences of elemToReplace with substitutionElem.


주어진 정수배열에서, elemToReplace 에 해당하는 정수를, substitutionElem 정수로 전부 바꿔라.



Example


Input -> inputArray = [1, 2, 1], elemToReplace = 1, and substitutionElem = 3


Output -> arrayReplace(inputArray, elemToReplace, substitutionElem) = [3, 2, 3].




//Process

//1. Input integer array, replaceNum, replaceVal

//2. Iterate begin to the end

// 2.1. Check if value is same as replaceNum

//  2.1.1. If so -> Change to replaceVal

//3. Return array



//처리과정

//1. 정수배열, 바꿔야할 정수, 바꿀 정수 입력받는다.

//2. 시작부터 끝까지 반복한다.

// 2.1. 바꿔야할 정수값이랑 같으면

//  2.1.1. -> 바꿀 정수값으로 바꾼다.

//3. 배열을 반환한다.




코드.. 코드를 보자....


Code.. lemme see code.....



std::vector<int> arrayReplace(std::vector<int> inputArray, int replaceNumber, int replaceValue) {

    

    for(int i = 0; i < inputArray.size(); ++i) 

    {

        if (inputArray[i] == replaceNumber) 

        {

            inputArray[i] = replaceValue;

        }

    }

    return inputArray;

}





Something else...




2018/11/09 - [Algorithm/Leet Code] - LeetCode problem #2 Add Two Numbers. Algorithm, 알고리즘, 코딩 문제풀이, LeetCode, 릿코드, 기술면접, CodeFights, CodeSignal, 코드파이트, 코드시그널, c++ java c#



2018/11/05 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #24 minesweeper. Algorithm, 알고리즘, Codefights, CodeSignal, regx, 정규표현식, 코드파이트, 코드시그널, c++ java c# scalar

2018/10/31 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #23 boxBlur. Algorithm, 알고리즘, Codefights, CodeSignal, regx, 정규표현식, 코드파이트, 코드시그널, c++ java c# scalar

2018/10/29 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #22 avoidObstacles. Algorithm, 알고리즘, Codefights, CodeSignal, regx, 정규표현식, 코드파이트, 코드시그널, c++ java c# scalar

2018/10/28 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #21 isIPv4Address. Algorithm, 알고리즘, Codefights, CodeSignal, regx, 정규표현식, 코드파이트, 코드시그널, c++ java c# scalar

2018/10/28 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #20 arrayMaximalAdjacentDifference. Algorithm, Codefights, CodeSignal, 코드파이트, 코드시그널, c++ java c# scalar

2018/10/27 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #19 AreEquallyStrong. Algorithm, Codefights, CodeSignal, 코드파이트, 코드시그널, c++ java c# scalar

2018/10/24 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #18 PalindromeRearranging, Codefights, CodeSignal, 코드파이트, 코드시그널, c++ java c# scalar

2018/10/24 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #17 ArrayChange, Codefights, CodeSignal, 코드파이트, 코드시그널, c++ java c# scalar

2018/10/21 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #16 AreSimilar?, Codefights, CodeSignal, 코드파이트, 코드시그널, c++ java c# scalar

2018/10/21 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #15 AddBorder, Codefights, CodeSignal, 코드파이트, 코드시그널, c++ java c# scalar

2018/10/20 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #14 AlternatingSums, Codefights, CodeSignal

2018/10/19 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #13 ReverseParentheses, Codefights, CodeSignal

2018/10/08 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #12 SortByHeight

2018/10/06 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #11 IsLucky

2018/10/03 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #10 CommonCharacterCount

2018/09/26 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #9 AllLongestStrings

2018/09/24 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #8 MatrixElementsSum

2018/09/23 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #7 AlmostIncreasingSequence

2018/09/22 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #6 MakeArrayConsecutive2

2018/09/21 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #5 ShapeArea

2018/09/19 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #4 AdjacentElementsProduct

2018/09/16 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #3 CheckPalindrome

2018/09/16 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #2 CenturyFromYear

2018/09/16 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #1 Add