summaryrefslogtreecommitdiff
path: root/find-in-mountain-array/src
diff options
context:
space:
mode:
Diffstat (limited to 'find-in-mountain-array/src')
-rw-r--r--find-in-mountain-array/src/main.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/find-in-mountain-array/src/main.rs b/find-in-mountain-array/src/main.rs
new file mode 100644
index 0000000..4fd6d7c
--- /dev/null
+++ b/find-in-mountain-array/src/main.rs
@@ -0,0 +1,28 @@
+fn main() {
+ println!("Hello, world!");
+}
+/**
+ * // This is the MountainArray's API interface.
+ * // You should not implement it, or speculate about its implementation
+ * struct MountainArray;
+ * impl MountainArray {
+ * fn get(index:i32)->i32;
+ * fn length()->i32;
+ * };
+ */
+
+struct MountainArray;
+
+impl MountainArray {
+ fn get(self, index:i32)->i32;
+ fn length(self)->i32;
+};
+
+impl Solution {
+ pub fn find_in_mountain_array(target: i32, mountainArr: &MountainArray) -> i32 {
+ for i in 0..mountainArr.length() {
+ if mountainArr.get(i) == target {return i;}
+ }
+ -1
+ }
+}