Diagonal Difference | HackerRank | Solution Explained - Python

preview_player
Показать описание
Diagonal Difference | HackerRank | 1 Week Preparation Kit

Thanks for watching! Please hit the like and subscribe! It would mean a lot :)

*Watch Some of My Other Videos to Master Problem Solving!*
_______________________

_______________________

*Watch Hackerranks 1 Week Interview Preparation Kit!*
_______________________

_______________________

#leetcode #leetcodequestionandanswers #programming #coding #python #interviewpreparation #faang #Leetcode, #LeetcodeQuestionAndAnswers, #Programming, #Coding, #Python, #InterviewPreparation, #FAANG, #CodingInterview, #ProgrammingTips, #CodingChallenge, #Algorithms, #DataStructures, #CodeWithMe, #ProblemSolving, #TechInterview, #CodingLife, #DevLife, #PythonProgramming, #PythonCode, #PythonDeveloper, #PythonCommunity, #PythonTutorial, #Developer, #SoftwareEngineering, #LearnProgramming, #100DaysOfCode, #WebDeveloper, #FAANGInterview, #TechCareer, #DevTips, #LearnCoding, #CodingBootcamp, #TechYouTuber, #TechContent, #CoderLife, #BuildInPublic, #LearnToCode, #SudokuProblems, #DailyCoding.
Рекомендации по теме
Комментарии
Автор

I just solved mine lol. I just notice that this is a 2d array, I thought it was 1D so I tried using square root of the array length. I love complicating things by not reading properly XD.

var length = arr.length;
var x = 0;
var y = 0;
arr.forEach((value, index) => {
x += arr[index][index];
y += arr[(length -1)-index][index];
});


return Math.abs(x-y);

lestherbualan
Автор

I like your approach to solving the problem! it help me understand better!

yannmarctenanteu
Автор

lef =0
rig=0
length = len(arr[0])
for count in range(length):
lef += arr[count][count]
rig += arr[count][(length-count-1)]
return dd(lef-rig)

shristisisodiya
Автор

arr_rev = [i[::-1] for i in arr]
sum_lt_rg_diag = [arr[i][i] for i in range(len(arr))]
sum_rg_lt_diag = [arr_rev[i][i] for i in range(len(arr_rev))]

return abs(sum(sum_lt_rg_diag) - sum(sum_rg_lt_diag))

FelipeSilva-wxzq
join shbcf.ru