diff --git a/BackTracking/sudoku.cpp b/BackTracking/sudoku.cpp new file mode 100644 index 0000000..60d9de4 --- /dev/null +++ b/BackTracking/sudoku.cpp @@ -0,0 +1,64 @@ +// Problem from GFG + +bool isSafe(int i, int j,int num,int grid[9][9]){ + for(int p=0;p<9;p++){ + if(grid[i][p]==num){ + return false; + } + if(grid[p][j]==num){ + return false; + } + } + + int s = sqrt(9); + i = i - (i%s); + j = j - (j%s); + for(int l =0;lp){ + sum = (sum%p); + } + } + return sum; +} diff --git a/Hashing/Group_anagrams_together.cpp b/Hashing/Group_anagrams_together.cpp new file mode 100644 index 0000000..e9979f2 --- /dev/null +++ b/Hashing/Group_anagrams_together.cpp @@ -0,0 +1,37 @@ +// Practice que from gfg +// Given an array of words, print the count of all anagrams together in sorted order (increasing order of counts). +// For example, if the given array is {“cat”, “dog”, “tac”, “god”, “act”}, then grouped anagrams are “(dog, god) (cat, tac, act)”. So the output will be 2 3. + + + +#include +#include +using namespace std; + +int main() { + int t; + cin>>t; + while(t--){ + vector v; + int N; + cin>>N; + string a[N]; + for(int i=0;i>a[i]; + } + unordered_map um; + for(int i=0;i