Apr 3, 202030 Day Leet Code Challenge #1 Single Number Java SolutionThis is my solution to problem 136 from Leetcode.com. Given a non-empty array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? Example 1: Input: [2,2,1] Output: 1 Example…Programming4 min readProgramming4 min read

Apr 1, 2020How to Solve Diagonal Traverse Algorithm in JavaThis is my solution to problem 498 on Leet Code. Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image. Example: Input: [ [ 1, 2, 3 ], [ 4, 5, 6 ], […Algorithms9 min readAlgorithms9 min read

Feb 25, 2019How to Solve Plus One Algorithm in JavaThis is my solution to problem 66 on Leet Code. Given a non-empty array of digits representing a non-negative integer, plus one to the integer. The digits are stored such that the most significant digit is at the head of the list, and each element in the array contain a…Programming4 min readProgramming4 min read

Feb 24, 2019How to solve Largest Number At Least Twice of Others Algorithm in JavaThis is my solution to problem 747 on Leet Code. In a given integer array nums, there is always exactly one largest element. Find whether the largest element in the array is at least twice as much as every other number in the array. If it is, return the index…Java6 min readJava6 min read

Feb 13, 2019How to Solve Pivot Index Algorithm in JavaThis is my solution to problem 724 on Leet Code. Given an array of integers nums, write a method that returns the "pivot" index of this array. We define the pivot index as the index where the sum of the numbers to the left of the index is equal to…Programming5 min readProgramming5 min read