Posts

Showing posts from May, 2023

Find the longest substring in a given string.

  Find the longest substring in a given string. Agoda round 1 on 31/05/2023 by Peter and Kuma Example #1: input: 'abcabc' output: 3 Example #2: input: 'bbbb' output: 1 Example #3: input: 'abb' output: 2 function solution ( s ) { const strLen = s . length ; let max = 0 ; let long = []; // b for ( let j = 0 ; j < strLen ; j ++) { // j = 1, b if ( long . indexOf ( s [ j ]) > - 1 ) { long = []; // push the curr char to the long list long . push ( s [ j ]); } else { // push the curr distinct char to the long list long . push ( s [ j ]); const longLen = long . length ; if ( longLen > max ) { max = longLen ; } } } return max ; } // Time complexity can be improved to O(n) by putting characters of the longest substring ('long' in the above code) in a map instead of list. /*{ ...

Find the robot matching the given query having [top, right, bottom, left] index of the nearest walls in a 2D array.

Find the robot matching the given query having [top, right, bottom, left] index of the nearest walls in a 2D array. Uber Round 1 on 23.05.2023 Incomplete solution below: // &----w // -&---w // --ww-w // --&--w // --&w-w // wall index: [top, right, bottom, left] const query = [4,2,3,1]; // q = robot // w = wall const arr = [ /* 0 */ [' ', ' ', ' ', 'w', 'w'], /* 1 */ [' ', 'q', ' ', 'w', 'w'], /* 2 */ [' ', ' ', ' ', 'w', 'w'], /* 3 */ ['w', ' ', 'q', 'w', 'w'], /* 4 */ ['q', ' ', ' ', 'w', 'w'], /* 0 1 2 3 4 */ ]; function findRobot(arr = [], query = []) { const maxRow = arr.length; const maxCol = arr[0].length; let robotIndexMapping = {}; // store walls found row wise let wallsMapByRowIndex = { // 0: undefined, // 1: undefined, // 2: undefined, // 3: undefin...

Abhijit Padhy

Image
ABHIJIT PADHY Lead Engineer Frontend at  Ringcentral About A passionate and results-driven software developer with 10 years of experience in architecting, building, and delivering large-scale web applications. Proficient in modern web technologies, I specialize in designing responsive, progressive web applications, and have a strong focus on agile practices, team management and continuous improvement. With a proven track record in enhancing application performance and collaborating across global teams, I am eager to leverage my technical expertise and leadership skills to transition into an engineering manager role. My goal is to lead high-performing teams, drive innovation, and contribute to the development of cutting-edge solutions that deliver lasting business impact.   Email :  abhijit.padhy@yahoo.com Linkedin :  https://in.linkedin.com/in/abhijit-padhy-07 Github:  https://github.com/abhijit-p...

Find if a string is palindrome using javascript

Checks if the given string is a palindrome using javascript @author: Abhijit Padhy  @github:  https://github.com/abhijit-padhy const checkIsGivenStringAPalindrome = ( str ) => { const stringLength = str.length; const mid = Math.floor(stringLength/2); let isPalindrome = true; let less = 1, more = 1; // For even number of letters the logic will be slightly different if (stringLength % 2 === 0) { more = 0; } for (let i = mid; i > 0; i--) { if (str[mid - less] !== str[mid + more]) { isPalindrome = false; } less = less + 1; more = more + 1; } return isPalindrome; }; checkIsGivenStringAPalindrome('madam'); // true checkIsGivenStringAPalindrome('iadaj'); // false checkIsGivenStringAPalindrome('paap'); // true Keywords: javascript, palindrome, coding, programming, java, interview, c, c++, node js