ehartford commited on
Commit
4df9203
1 Parent(s): 051ac83

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +49 -0
README.md CHANGED
@@ -73,6 +73,55 @@ Please give ideas and a detailed plan about how to assemble and train an army of
73
 
74
  <img src="https://cdn-uploads.huggingface.co/production/uploads/63111b2d88942700629f5771/RQ9ovFrmT3f64WAlfBHY6.png" width="600" />
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  ## Future Plans
77
  Dolphin 3.0 dataset is in progress, and will include:
78
  - enhanced general chat use-cases
 
73
 
74
  <img src="https://cdn-uploads.huggingface.co/production/uploads/63111b2d88942700629f5771/RQ9ovFrmT3f64WAlfBHY6.png" width="600" />
75
 
76
+ ```
77
+ $ ollama run dolphin "choose a leetcode hard problem, solve it in Kotlin"
78
+
79
+ Sure, I can do that. Let's choose the problem "Find Largest Submatrix with All Ones" from LeetCode.
80
+
81
+ Here is the problem statement:
82
+ Given a boolean 2D matrix where each row is sorted in non-decreasing order and all columns are also sorted in non-decreasing order, find
83
+ the largest submatrix that contains only ones.
84
+
85
+ Here is the solution in Kotlin:
86
+
87
+ fun largestSubmatrix(matrix: Array<IntArray>): Int {
88
+ if (matrix.isEmpty()) return 0
89
+
90
+ val rows = matrix.size
91
+ val cols = matrix[0].size
92
+
93
+ // initialize dynamic programming array with all zeros
94
+ val dp = Array(rows) { IntArray(cols) }
95
+
96
+ // iterate through each column in the matrix
97
+ for (c in 0 until cols) {
98
+ for (r in 0 until rows) {
99
+ // if current cell is one, update dp value with min of row and dp[r - 1][c]
100
+ if (matrix[r][c] == 1) {
101
+ dp[r][c] = r.coerceAtMost(dp[r - 1][c] + 1)
102
+ }
103
+ }
104
+ }
105
+
106
+ // find the maximum value in the dp array
107
+ var maxArea = 0
108
+ for (r in 0 until rows) {
109
+ for (c in 0 until cols) {
110
+ if (dp[r][c] != 0) {
111
+ val area = dp[r][c] * (cols - c)
112
+ maxArea = maxOf(maxArea, area)
113
+ }
114
+ }
115
+ }
116
+
117
+ return maxArea
118
+ }
119
+ This function takes a 2D boolean matrix as input and returns the size of the largest submatrix with all ones. The algorithm uses dynamic
120
+ programming to keep track of the width of the current row for every column. Then it updates the maximum size of the submatrix by
121
+ considering each row in the matrix.
122
+ ```
123
+
124
+
125
  ## Future Plans
126
  Dolphin 3.0 dataset is in progress, and will include:
127
  - enhanced general chat use-cases