From 4e72314e22c8c8952a782bfc58deca2dc404819e Mon Sep 17 00:00:00 2001 From: Hiran Raj Date: Fri, 9 May 2025 20:32:10 +0530 Subject: [PATCH 1/8] Create answer.md file for the application. --- answer.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 answer.md diff --git a/answer.md b/answer.md new file mode 100644 index 0000000..e69de29 From c987bacc18fc71fcdefcc5037ca925d39f46c738 Mon Sep 17 00:00:00 2001 From: Hiran Raj Date: Fri, 9 May 2025 20:54:41 +0530 Subject: [PATCH 2/8] Add personal information and development environment details --- answer.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/answer.md b/answer.md index e69de29..3f9c3c5 100644 --- a/answer.md +++ b/answer.md @@ -0,0 +1,36 @@ +About You + +1. Introduce yourself. +I'm Hiran Raj, a dedicated Software Engineer from Chengannur, Alappuzha. I specialize in building and deploying web applications with a strong focus on backend development. I'm a BCA graduate who is passionate about creating clean, maintainable code and continuously expanding my technical knowledge to stay at the forefront of software development innovation. + +2. Do you own a personal computer? +Yes, I own a personal computer that I use for both work and personal projects. + +3. Describe your development environment. (Your OS, IDE, Editor and Config manager if any) +My development environment consists of: + +Hardware: HP Pavilion +OS: Windows 10 as my primary operating system +IDE/Editor: + +Visual Studio Code as my primary editor with extensions for: + +JavaScript/TypeScript development +React/Redux +Tailwind CSS IntelliSense +ESLint for code quality +Prettier for code formatting +Git integration + + +Version Control: Git with GitHub for repositories +Configuration Management: + +Docker for containerization and consistent development environments +nvm for Node.js version management +AWS CLI for cloud resource management + + +Package Managers: npm +API Testing: Postman for API testing and documentation +Database Tools: MongoDB Compass, pgAdmin for database management \ No newline at end of file From ad56f1fd00de8b2f1fd04ee3f1e64a2364acdda0 Mon Sep 17 00:00:00 2001 From: Hiran Raj Date: Fri, 9 May 2025 21:04:16 +0530 Subject: [PATCH 3/8] Add social profile information --- answer.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/answer.md b/answer.md index 3f9c3c5..91268f6 100644 --- a/answer.md +++ b/answer.md @@ -33,4 +33,15 @@ AWS CLI for cloud resource management Package Managers: npm API Testing: Postman for API testing and documentation -Database Tools: MongoDB Compass, pgAdmin for database management \ No newline at end of file +Database Tools: MongoDB Compass, pgAdmin for database management + + +Social Profile +1. Your StackOverflow Profile url. +https://stackoverflow.com/users/30493273/hiran-raj +2. Personal website, blog or something you want us to see. + +GitHub Profile: https://github.com/Hiran-2001 +LinkedIn: https://www.linkedin.com/in/hiran-raj/ +Resume: https://docs.google.com/document/d/10lMr9inuePstTwHrW9buhj3SjoJ4owhGQlWfX9l04O4/edit?tab=t.0 + From 9f89e9c54bf17c883b8b6dbe75d314d1b25f0d5d Mon Sep 17 00:00:00 2001 From: Hiran Raj Date: Fri, 9 May 2025 21:10:34 +0530 Subject: [PATCH 4/8] List installed programming languages --- answer.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/answer.md b/answer.md index 91268f6..93cbc5e 100644 --- a/answer.md +++ b/answer.md @@ -45,3 +45,13 @@ GitHub Profile: https://github.com/Hiran-2001 LinkedIn: https://www.linkedin.com/in/hiran-raj/ Resume: https://docs.google.com/document/d/10lMr9inuePstTwHrW9buhj3SjoJ4owhGQlWfX9l04O4/edit?tab=t.0 + +The real stuff. +1. Which all programming languages are installed on your system. +The following programming languages are installed on my system: + +JavaScript/Node.js (v20.10.0) +TypeScript (v5.0.4) +Python (v3.12.4) +Java (OpenJDK 19.0.1) +Go (go1.24.2) From f65cd5809b99138cdea134966d57707564f1f074 Mon Sep 17 00:00:00 2001 From: Hiran Raj Date: Fri, 9 May 2025 21:34:59 +0530 Subject: [PATCH 5/8] Implement function to convert number to digits array --- answer.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/answer.md b/answer.md index 93cbc5e..1c7db8c 100644 --- a/answer.md +++ b/answer.md @@ -55,3 +55,19 @@ TypeScript (v5.0.4) Python (v3.12.4) Java (OpenJDK 19.0.1) Go (go1.24.2) + + +2. Write a function that takes a number and returns a list of its digits in an array. + +javascript/** + * Takes a number and returns an array of its digits + +const getDigits = (num) => { + const absNum = Math.abs(num); // Handle negative numbers + return absNum.toString().split('').map(digit => parseInt(digit)); +}; + +// Test cases +console.log(getDigits(5236)); // [5, 2, 3, 6] +console.log(getDigits(0)); // [0] +console.log(getDigits(-5236)); // [5, 2, 3, 6] \ No newline at end of file From 79e9462cf20b11da1442a759b454082e064f23ca Mon Sep 17 00:00:00 2001 From: Hiran Raj Date: Fri, 9 May 2025 21:44:52 +0530 Subject: [PATCH 6/8] Implement function to remove array duplicates --- answer.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/answer.md b/answer.md index 1c7db8c..1a74e01 100644 --- a/answer.md +++ b/answer.md @@ -57,9 +57,9 @@ Java (OpenJDK 19.0.1) Go (go1.24.2) -2. Write a function that takes a number and returns a list of its digits in an array. +2. Write a function that takes a number and returns a list of its digits in an array ? -javascript/** +javascript * Takes a number and returns an array of its digits const getDigits = (num) => { @@ -70,4 +70,18 @@ const getDigits = (num) => { // Test cases console.log(getDigits(5236)); // [5, 2, 3, 6] console.log(getDigits(0)); // [0] -console.log(getDigits(-5236)); // [5, 2, 3, 6] \ No newline at end of file +console.log(getDigits(-5236)); // [5, 2, 3, 6] + + +3. Remove duplicates of an array and returning an array of only unique elements ? + +javascript + * Takes an Array with duplicate numbers and removes duplicates from the array + +const getUniqueElements = (arr) => { + return [...new Set(arr)]; +}; + +//Test cases +console.log(getUniqueElements([1, 2, 2, 3, 4, 4, 5])); //Output [1, 2, 3, 4, 5] +console.log(getUniqueElements(['a', 'b', 'a', 'c', 'b'])) // Output // ['a', 'b', 'c'] \ No newline at end of file From ebc237e3ed354210aa793eedfbc589426c4c8824 Mon Sep 17 00:00:00 2001 From: Hiran Raj Date: Mon, 12 May 2025 18:01:30 +0530 Subject: [PATCH 7/8] Implement Pig Latin translator function --- answer.md | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/answer.md b/answer.md index 1a74e01..f754356 100644 --- a/answer.md +++ b/answer.md @@ -84,4 +84,79 @@ const getUniqueElements = (arr) => { //Test cases console.log(getUniqueElements([1, 2, 2, 3, 4, 4, 5])); //Output [1, 2, 3, 4, 5] -console.log(getUniqueElements(['a', 'b', 'a', 'c', 'b'])) // Output // ['a', 'b', 'c'] \ No newline at end of file +console.log(getUniqueElements(['a', 'b', 'a', 'c', 'b'])) // Output // ['a', 'b', 'c']; + + +4. Write function that translates a text to Pig Latin and back. English is translated to Pig Latin by taking the first letter of every word, moving it to the end of the word and adding ‘ay’. “The quick brown fox” becomes “Hetay uickqay rownbay oxfay”. + +javascript + + function toPigLatin(text) { + const words = text.split(' '); + const pigLatinWords = []; + + for (let i = 0; i < words.length; i++) { + const word = words[i]; + + if (word.length <= 1) { + pigLatinWords.push(word); + continue; + } + + const isCapitalized = word[0] === word[0].toUpperCase(); + + const pigLatinWord = word.slice(1) + word[0] + 'ay'; + + if (isCapitalized) { + pigLatinWords.push( + pigLatinWord[0].toUpperCase() + + pigLatinWord.slice(1).toLowerCase() + ); + } else { + pigLatinWords.push(pigLatinWord.toLowerCase()); + } + } + + return pigLatinWords.join(' '); +} + +function toEnglish(text) { + const words = text.split(' '); + + const englishWords = []; + + for (let i = 0; i < words.length; i++) { + const word = words[i]; + + if (word.length <= 3) { + englishWords.push(word); + continue; + } + + if (!word.toLowerCase().endsWith('ay')) { + englishWords.push(word); + continue; + } + + const isCapitalized = word[0] === word[0].toUpperCase(); + + const englishWord = word[word.length - 3] + + word.slice(0, word.length - 3); + + if (isCapitalized) { + englishWords.push( + englishWord[0].toUpperCase() + + englishWord.slice(1).toLowerCase() + ); + } else { + englishWords.push(englishWord.toLowerCase()); + } + } + + return englishWords.join(' '); +} + +console.log(toPigLatin("The quick brown fox")); // Output: "Hetay uickqay rownbay oxfay" + +console.log(toEnglish("Hetay uickqay rownbay oxfay")); // Output: "The quick brown fox" + From 21fc4f567e4013a3e75cd096b1fa08cf1b39301c Mon Sep 17 00:00:00 2001 From: Hiran Raj Date: Mon, 12 May 2025 18:02:15 +0530 Subject: [PATCH 8/8] Implement efficient array rotation function --- answer.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/answer.md b/answer.md index f754356..673b58d 100644 --- a/answer.md +++ b/answer.md @@ -160,3 +160,30 @@ console.log(toPigLatin("The quick brown fox")); // Output: "Hetay uickqay rownba console.log(toEnglish("Hetay uickqay rownbay oxfay")); // Output: "The quick brown fox" + +5. Write a function that rotates a list by k elements. For example [1,2,3,4,5,6] rotated by 2 becomes [3,4,5,6,1,2]. Try solving this without creating a copy of the list. How many swap or move operations do you need? + +javascript + * Rotates an array by k elements in-place + +const rotateInPlace = (arr, k) => { + const n = arr.length; + k = k % n; + + + const reverse = (start, end) => { + while (start < end) { + [arr[start], arr[end]] = [arr[end], arr[start]]; + start++; + end--; + } + }; + + reverse(0, k - 1); + reverse(k, n - 1); + reverse(0, n - 1); +}; + +const arr = [1, 2, 3, 4, 5]; +rotateInPlace(arr, 3); +console.log(arr); // Output: [4, 5, 1, 2, 3] \ No newline at end of file