<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: deepi907</title>
    <description>The latest articles on DEV Community by deepi907 (@deepi907).</description>
    <link>https://dev.to/deepi907</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1328867%2F50e98bfa-543e-4624-9a8e-71ef6b93e161.png</url>
      <title>DEV Community: deepi907</title>
      <link>https://dev.to/deepi907</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/deepi907"/>
    <language>en</language>
    <item>
      <title>solved leetcode sudoko problem using Hashmap</title>
      <dc:creator>deepi907</dc:creator>
      <pubDate>Wed, 28 Aug 2024 09:43:58 +0000</pubDate>
      <link>https://dev.to/deepi907/solved-leetcode-sudoko-problem-using-hashmap-2hi1</link>
      <guid>https://dev.to/deepi907/solved-leetcode-sudoko-problem-using-hashmap-2hi1</guid>
      <description>&lt;p&gt;`&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;class Solution {

&lt;ol&gt;
&lt;li&gt;    public void solveSudoku(char[][] board) {&lt;/li&gt;
&lt;li&gt;        HashMap&amp;gt; rows = new HashMap&amp;lt;&amp;gt;();&lt;/li&gt;
&lt;li&gt;        HashMap&amp;gt; cols = new HashMap&amp;lt;&amp;gt;();&lt;/li&gt;
&lt;li&gt;        HashMap&amp;gt; boxes = new HashMap&amp;lt;&amp;gt;();&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;/ol&gt;

&lt;p&gt;Here three hashmap used that is &lt;strong&gt;row,cols,and boxes&lt;/strong&gt; Now &lt;br&gt;
it will efficiently keep track of which numbers are already used in each row, column, and 3x3 sub-box of the Sudoku board.&lt;/p&gt;

&lt;p&gt;Each entry in these hashmaps is a HashSet to store characters representing numbers.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;        // Initialize hashmaps&lt;/li&gt;
&lt;li&gt;        for (int i = 0; i &amp;lt; 9; i++) {&lt;/li&gt;
&lt;li&gt;            rows.put(i, new HashSet&amp;lt;&amp;gt;());&lt;/li&gt;
&lt;li&gt;            cols.put(i, new HashSet&amp;lt;&amp;gt;());&lt;/li&gt;
&lt;li&gt;            boxes.put(i, new HashSet&amp;lt;&amp;gt;());&lt;/li&gt;
&lt;li&gt;        }&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;        // Fill the hashmaps with the existing numbers on the board&lt;/li&gt;
&lt;li&gt;        for (int r = 0; r &amp;lt; 9; r++) {&lt;/li&gt;
&lt;li&gt;            for (int c = 0; c &amp;lt; 9; c++) {&lt;/li&gt;
&lt;li&gt;                char num = board[r][c];&lt;/li&gt;
&lt;li&gt;                if (num != '.') {&lt;/li&gt;
&lt;li&gt;                    rows.get(r).add(num);&lt;/li&gt;
&lt;li&gt;                    cols.get(c).add(num);&lt;/li&gt;
&lt;li&gt;                    int boxIndex = (r / 3) * 3 + c / 3;&lt;/li&gt;
&lt;li&gt;                    boxes.get(boxIndex).add(num);&lt;/li&gt;
&lt;li&gt;                }&lt;/li&gt;
&lt;li&gt;            }&lt;/li&gt;
&lt;li&gt;        }&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;        // Start solving the puzzle using backtracking&lt;/li&gt;
&lt;li&gt;        solve(board, rows, cols, boxes, 0, 0);&lt;/li&gt;
&lt;li&gt;    }&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;    private boolean solve(char[][] board, HashMap&amp;gt; rows, HashMap&amp;gt; cols, HashMap&amp;gt; boxes, int r, int c) {&lt;/li&gt;
&lt;li&gt;        if (r == 9) return true; // Puzzle solved&lt;/li&gt;
&lt;li&gt;        if (c == 9) return solve(board, rows, cols, boxes, r + 1, 0);&lt;/li&gt;
&lt;li&gt;        if (board[r][c] != '.') return solve(board, rows, cols, boxes, r, c + 1);&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;        int boxIndex = (r / 3) * 3 + c / 3;&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;        // Try placing numbers from 1 to 9&lt;/li&gt;
&lt;li&gt;        for (char num = '1'; num &amp;lt;= '9'; num++) {&lt;/li&gt;
&lt;li&gt;            if (!rows.get(r).contains(num) &amp;amp;&amp;amp; !cols.get(c).contains(num) &amp;amp;&amp;amp; !boxes.get(boxIndex).contains(num)) {&lt;/li&gt;
&lt;li&gt;                // Place the number&lt;/li&gt;
&lt;li&gt;                board[r][c] = num;&lt;/li&gt;
&lt;li&gt;                rows.get(r).add(num);&lt;/li&gt;
&lt;li&gt;                cols.get(c).add(num);&lt;/li&gt;
&lt;li&gt;                boxes.get(boxIndex).add(num);&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;                // Continue solving with the next empty cell&lt;/li&gt;
&lt;li&gt;                if (solve(board, rows, cols, boxes, r, c + 1)) return true;&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;                // Backtrack&lt;/li&gt;
&lt;li&gt;                board[r][c] = '.';&lt;/li&gt;
&lt;li&gt;                rows.get(r).remove(num);&lt;/li&gt;
&lt;li&gt;                cols.get(c).remove(num);&lt;/li&gt;
&lt;li&gt;                boxes.get(boxIndex).remove(num);&lt;/li&gt;
&lt;li&gt;            }&lt;/li&gt;
&lt;li&gt;        }&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;        return false; // No valid solution found, backtrack&lt;/li&gt;
&lt;li&gt;    }&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;}
When backtracking, removing a number from the hashmaps is straightforward and ensures that all constraints are maintained.&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    <item>
      <title>wordle</title>
      <dc:creator>deepi907</dc:creator>
      <pubDate>Wed, 10 Jul 2024 13:48:45 +0000</pubDate>
      <link>https://dev.to/deepi907/wordle-394j</link>
      <guid>https://dev.to/deepi907/wordle-394j</guid>
      <description>&lt;p&gt;i took this challenge as frontend developer.Wordle is a daily word guessing game. Players guess a secret 5-letter word, receiving feedback on correct letters and positions. Implemented with HTML/CSS for interface and JavaScript for logic, it fetches words from an API, validates guesses, and tracks remaining attempts for a complete gaming experience."&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/deepi907/embed/eYwmEbR?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
      <category>css</category>
      <category>javascript</category>
      <category>html</category>
    </item>
  </channel>
</rss>
