
Aspiring Software Developer 👩💻 Open source 📖Learning:- Python with DSA, javascript 🔭
- Tweets621
- Following400
- Followers396
- Likes818

ALT Problem no 1 :- Sort characters by frequency https://leetcode.com/problems/sort-characters-by-frequency/ Breakdown :- The Java solution for sorting a string `s` in decreasing order based on character frequency employs a systematic approach. Initially, a HashMap is utilized to count the frequency of each character in the input string. This involves iterating through the string and updating the count of each character in the HashMap. Next, a list of unique characters is created from the keys of the frequency map. These characters are sorted in non-increasing order based on their frequencies, achieved through a custom comparator. Finally, a StringBuilder is used to construct the sorted string by iterating through the sorted characters and appending each character to the result string according to its frequency. This approach ensures the efficient sorting of characters by frequency, enabling the creation of the desired sorted string in decreasing order of frequency.

ALT Problem no2 :- atoi https://leetcode.com/problems/string-to-integer-atoi/ Breakdown:- The Java implementation of the `myAtoi` function efficiently converts a given string into a 32-bit signed integer, following a defined algorithm. Initially, the function initializes variables for the current index, sign, and total sum. It proceeds to ignore any leading whitespace characters by incrementing the index until a non-whitespace character is encountered. Subsequently, it determines the sign of the integer by examining the next character. If a '-' or '+' is present, the sign is adjusted accordingly, and the index is incremented. The function then iterates through the string, parsing digits and accumulating the total sum while handling potential overflow conditions. If the parsed integer exceeds the range of a 32-bit signed integer, the function returns the corresponding maximum or minimum value. Finally, the sign is applied to the total sum, and the result is returned as the final output.

ALT Problem no 1 :- Set Matrix Zeros https://leetcode.com/problems/set-matrix-zeroes/ Breakdown of the code :- To solve the problem of setting rows and columns to zero in a given matrix if an element is zero, we can use a constant space solution. The idea is to use the first row and first column of the matrix itself to keep track of which rows and columns should be zeroed.

ALT Problem no 2 :- Rotate Matrix my 90deg https://leetcode.com/problems/rotate-image/ Breakdown of the code:-The provided Java solution for rotating an `n x n` 2D matrix by 90 degrees clockwise in place involves two main steps: transposing the matrix and then reversing each row. Initially, the length of the matrix is stored in `n`. The first step, transposing the matrix, involves iterating through the upper triangle of the matrix (excluding the diagonal). For each element at position `(i, j)`, it swaps the element with the corresponding element at position `(j, i)`, effectively turning rows into columns. This is accomplished using nested loops where the inner loop starts from `i` to avoid redundant swaps. The second step is to reverse each row to complete the 90-degree rotation. This is done by iterating through each row and swapping elements from the start with elements from the end until reaching the middle of the row.

ALT Problem no 3 :-Print Matrix in spiral https://leetcode.com/problems/spiral-matrix/ Breakdown :- The Java solution efficiently obtains the elements of an `m x n` matrix in spiral order through systematic traversal. Initially, an empty list is created to hold the spiral-ordered elements, with an early return if the matrix is empty. Boundaries for the top, bottom, left, and right edges are set. The function then enters a while loop, continuing as long as the top boundary is less than or equal to the bottom boundary and the left boundary is less than or equal to the right boundary. Within the loop, four nested loops traverse the matrix according to the specified pattern: left to right along the top row, top to bottom along the right column, right to left along the bottom row (if applicable), and bottom to top along the left column. Each traversed element is added to the result .











